UICollectionView适用于iOS7但不适用于iOS6

m.y*_*m.y 8 ios ios6 uicollectionview uicollectionviewlayout ios7

我的UICollectionView单元格没有显示在iOS6上,因为我的委托方法cellForItemAtIndexPath没有被调用.我怀疑是因为这个警告:

 the behavior of the UICollectionViewFlowLayout is not defined because:
 the item height must be less that the height of the `UICollectionView`
 minus the section inset's top and bottom values.
Run Code Online (Sandbox Code Playgroud)

我没有在iOS7上收到警告,所有单元格也在那里正确显示.

我已将collectionView框架设置为高度270,.xib并且没有定义任何插图.我把我的细胞高度设置为270 .xib.我可以collectionView在运行时打印出我的帧,它是271.

此外,我collectionview实际上是在自定义tableview单元格内.

有任何想法吗?谢谢!

小智 8

尝试设置 self.automaticallyAdjustsScrollViewInsets = NO

这是在中引入的,所以如果你支持及以下版本,你可能想用版本检查来包装它.


m.y*_*m.y 4

这解决了我的问题!在我的中.xib,将我的集合视图大小单元格大小设置为较小的值。

我的设置是,我将其放在collectionview自定义tableview单元格内,并且我以编程方式返回单元格的高度tableview(取决于内容)。所以我的警告可能与我collectionview不适应牢房有关tableview。因此将初始值设置collectionview为较小的值即可解决此问题。

我误以为问题出在我collectionview和它的colletionview细胞上。

或许?