Question

I have a UICollectionView in a storyboard (iPad). I'm not setting any properties (margins, sizes etc.) programatically - my delegate only implements the mandatory methods (number of sections & items, cellForItemAtIndexPath). I'm using the standard flow layout, with horizontal scrolling (1 row), and no top/bottom insets. I have a custom cell class, but again, nothing fancy (just IBOutlets for some labels and an imageView). My cells are 100x100px. The collectionView has its height set to 100px, and IB shows it as such.

attributes inspector size inspector

However, when I run the app I get the collectionView rendered as 140px in height (with a 20px margin above and below the cells). I played with different values for all properties (including the min spacing) but couldn't make the view any shorter - I can only make it taller by changing the insets.

Is this a bug or am I missing some logic that I cannot circumvent, e.g. the standard layout will forcefully include some minimum spacing above & below its contents?

Was it helpful?

Solution

For me the solution was to disable "adjust scroll view insets" on the view controller that has the collection view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top