Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Photo Browser iPhone App Collection Views Customizing a UICollectionViewFlowLayout

thibaut noah
thibaut noah
8,692 Points

minimumInteritemSpacing not working

I don't get it, i have the exact same code (or i have troubles reading) and yet the line of code assigning a value to minimumInteritemSpacing doesn't do anything? minimumLineSpacing is working like a charm btw. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(106.0, 106.0); layout.minimumInteritemSpacing = 1.0; layout.minimumLineSpacing = 1.0;

return (self = [super initWithCollectionViewLayout:layout]);

2 Answers


Which device are you simulating when you run your app?

When I run using the iPhone 4s sim, it looks pretty exactly like the video. When I run using the iPhone 6s sim, there are much bigger gaps between the cells.

So looks like it's due to the resolution (?) of the screen on different devices.

Is that what you're seeing?

I expect that to get it having the squares right for all devices, needs to have the 106.0 x 106.0 be dynamically calculated - a problem for another day for me I think.


Ravin Kohli
Ravin Kohli
3,367 Points

for iphone 6 you can use 124.0f as your parameters for the cgsizemake method