UICollectionView Custom Layout Tutorial: Pinterest

am also trying to find a solution. no luck. did you manage to do it? if so, how? :slight_smile:

1 Like

Do anyone know how to add a supplementary view for a header of the custom collectionView layout?

Nice tutorial! Very helpful

Hey guys, thanks for the great tutorial :slight_smile: I notice it has been updated for swift !

Thatโ€™s awesome, but is an objC version still available ? In order to smoothly integrate it in an older project that doesnโ€™t have any Swift in it

Thanks in advance !

Just wanted to say that this article save my day or probably three or four days. Anyway, thank you very much!

I was using this layout, and had it working at one point, but now it crashes inside the line in the file AnnotatedPhotoCell.swift:

imageViewHeightLayoutConstraint.constant = attributes.photoHeight

It says that imageViewHeightLayoutConstraint is nil, even though the constraint appears in my storyboard and as an outlet in the AnnotatedPhotoCell class. Any idea what might be causing this?

Has anyone managed to use that example with images from URL?
And if so how?
Thanks!

did you transfer this to UICollectionView? will you please send your file here im having trouble with mine. Thank you in advance jose

Had the same problem; Given that you can customise the appearance of each cell giving them the size and position, I made the first cell as the header, bigger and in the center of the collection and then I moved all the other following cell down.
Hope I helped

I converted this to Swift 3 beginning with the starter code and through every steop and it works as described. Great tutorial. Thanks!

Kindly share this project on swift 3 or send to alex@vectech.ru
Iโ€™ll be very grateful

I created a GIT repository for this. Let me know if you have any problems (this is my first one).

https://github.com/AZCoder2/Pinterest.git

All works, Many Thanks!

Glad to help! Have a happy New Year. :grinning: :beers:

Iโ€™m trying to write this app programmatically without using storyboard. Can you have a look and help fix my codes?

Sorry, Iโ€™m no expert! Iโ€™m learning just like you. Good luck!

Hi, i want to reload my collection view data after calling more products api and my cell size should change according to the image size can any one help for me

I kind of solve this by adding an attribute for header before I add the attributes for other items, then make the yOffsets of the following items start with the below of header:

    UICollectionViewLayoutAttributes *headerAtt = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathWithIndex:0]];
    headerAtt.frame = CGRectMake(0, 0, _width, 200);
    [_cache addObject:headerAtt];

Iโ€™ve used this in the past with success - but lately, Iโ€™ve been developing without using storyboards and I cannot get this to work at all.The layout is just a complete mess - cells have incorrect dimensions and are placed at the wrong location. Has anybody used this without storyboards and had any success with it?

Thanks

Hello and thank you for your job! Any chance for writing tutorial where UICollectionViewFlowLayoutAutomaticSize use for this?