Nested Header Collection View
AppStore JSON APIs
Headers are an extremely useful for rendering a portion of your list that isn't based on an array of information. For example, in our app we need a header that contains some highlighted apps for our product. In this lesson, we'll go over how to register and dequeue this supplementary view for our UICollectionView component.

Comments (11)
rmsdevios
4 years ago
Hey brian, This seems to be video 12, but it is listed to the right side of the page like 15.
Brian Voong
4 years ago
Tube
4 years ago
I really like this method of using child view controllers. But, I don't like using convenience inits that don't do a full job, because the setup code gets split between the instantiation and the miscellaneous setup below it. So, maybe do it like this: let appIcon : UIImageView = { let appIcon = UIImageView(cornerRadius: 8) appIcon.backgroundColor = .green return appIcon }
compuuterjuice
4 years ago
Hey Brian, When adding collectionView.register(AppsPageHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerCellId) I'm getting an error: [Type 'UICollectionView' has no member 'elementsKindSectionHeader'] Any idea what is causing this ?
Brian Voong
4 years ago
compuuterjuice
4 years ago
NVM! I think this may be a subtle difference because I am using swift 4.1 still. It was fixed by using UICollectionElementKindSectionHeader in place of UICollectionView.elementKindSectionHeader
nguyentruongky
4 years ago
Hi Brian, any conveniences to embed the controller into header (or cell in previous video) instead of add UICollectionView into header (or cell)?
dog
4 years ago
Wondering why you don't use child.didMove(toParent: self) when adding child view controllers. More info here: https://www.swiftbysundell.com/posts/using-child-view-controllers-as-plugins-in-swift Enjoying the course so far.
dog
4 years ago
FYI: I posted above on April 20th, but saying 4 weeks ago
Tokyojogo
4 years ago
I'm curious to see how this is handled since we added it inside the cell. Any thoughts Brian?
sethdanner
4 years ago
You remind me of the late PBS painter Bob Ross- He was able to make the best looking paintings with such ease and making it look so easily doable. On top of that he had the most calm and peaceful demeanor. You are Bob Ross of apps!
sethdanner
4 years ago
Thank you for being a great guide and mentor!
Stewart Lynch
4 years ago
HI Brian. Instead of using the supplementary view for the nested header collection, could you have also just used two child collectionView Controllers inside a parent ViewController? One for the header type section and one for the app groups?
Brian Voong
4 years ago
chibuike
3 years ago
Hey Brian on my header when I scroll my cell disappears
dclawson
3 years ago
Did you get that figured out? Try downloading the project file and then comparing your code to the finished product. That helps sometimes.
Portocarrero Lopez Pedro
3 years ago
i had same problem. because in appsPageHeader. i wrote let appHeaderHorizøntalController = AppHeaderHorizontalController(). inside the override init(frame: CGRect) { super.init(frame: frame){ //code } } it must be before that(check . hope i helps. check 8:17.
dclawson
3 years ago
Not sure if this helps anyone, but I spent like 30min trying to get the registration of the header view to autocomplete. I restarted XCode a few times, did some research, and nada. I finally just went ahead with the other methods, built and ran and got the expected crash. As soon as I went back and tried it again, the autocomplete came right up.
Nikhil Pandey
3 years ago
Hi Brian, How to handle device rotation in collection view controller inside another collection view cell. In this case after rotating the device, the collection view embedded inside collection view changes size but doesn't revert to the size again on the device rotation.
Brian Voong
3 years ago
Navdeep Paliwal
3 years ago
xcvxcvxcv
HELP & SUPPORT