Search code examples
iosios6ios7uicollectionviewuicollectionviewlayout

UICollectionView working on iOS7 but not on iOS6


My UICollectionView cells don't get displayed on iOS6, because my delegate method cellForItemAtIndexPath doesn't get called. I suspect because of this warning:

 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.

I don't get the warning on iOS7, and all the cells display correctly there too.

I've set my collectionView frame to height 270 in the .xib and there are no insets defined. I've set my cell height to 270 in the .xib. I can print out my collectionView frame at runtime and it's 271.

Also, my collectionview is actually inside a custom tableview cell.

Any ideas? Thanks!


Solution

  • This fixed my problem! In my .xib, setting my Collection View Size Cell Size to a smaller value.

    My setup is that I have this collectionview inside a custom tableview cell and I do return the height of my tableview cell programatically (depending on the content). So it could be that my warnings had to do with my collectionview not fitting inside the tableview cell. So setting the initial collectionview to a smaller value fixed it.

    I was on the wrong path thinking that the problem was with my collectionview and its colletionview cell.

    Maybe?