美文网首页
2018-04-13

2018-04-13

作者: 破壊神 | 来源:发表于2018-04-13 18:22 被阅读0次

记录一下使用 collectionview 中遇到的坑

Cell中嵌套collectionview 造成的 itemSize 问题 

2018-04-13 18:12:20.969916+0800 comicvwdl[10718:407780] The behavior of the UICollectionViewFlowLayout is not defined because:2018-04-13 18:12:20.970082+0800 comicvwdl[10718:407780] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.2018-04-13 18:12:20.970294+0800 comicvwdl[10718:407780] The relevant UICollectionViewFlowLayout instance is, and it is attached to; layer =; contentOffset: {0, 0}; contentSize: {0, 278}; adjustedContentInset: {0, 0, 0, 0}> collection view layout:.

2018-04-13 18:12:20.970407+0800 comicvwdl[10718:407780] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

原因:Cell 的分割线(separator)造成的

这个问题是由于cell中装有一个collectionView, 在layoutSubView的时候,self.contentView的 frame 会减去separator的height(separator的height默认等于1);导致itemSize.height大于collectionView的height

解决方法:设置cell高度的时候 在原本计算好的高度上+1

相关文章

网友评论

      本文标题:2018-04-13

      本文链接:https://www.haomeiwen.com/subject/tkrhkftx.html