Apologies
You must be signed in to watch this lesson.
Favorite Podcast Cell in Code UIStackView
Podcasts
With our collection view correctly display our cells in a 2 column grid, we're now ready to implement a design for each cell. We'll first start by registering a custom UICollectionViewCell. Then let's add in the rest of our UI elements with code by utilizing the power of UIStackViews. Enjoy.

Comments (3)
rehannali
6 years ago
Hi Brain! Thanks for this course. You are an excellent teacher regarding teaching code. I've question in my mind, Why you haven't use the pod for auto layouts like there is viral library Snapkit an autolayout DSL for iOS and OSX.
Brian Voong
6 years ago
rehannali
6 years ago
I use it in a lot of projects while designing interface in code. It helps me to write code faster than usual. We also get rid of repetitive statements to active constraints and most of the time I forgot to active. Thanks for considering my opinion.
gottaminute
5 years ago
Hi Brian, I'm trying to run the fetchJSON() func in the controller file or should I run it in the cell file? In the cell file it has... var imageView = UIImageView(image: xxx) in the controller file I have the fetchJSON() func with JSONDecoder()... self.collectionView?.reloadData() which send it to collectionView cellForItemAt... But I'm getting this error... Value of type 'UICollectionViewCell' has no member 'imageView' when using this in the cellForItemAt func cell.imageView.sd_setImage(with: url, completed: nil) I'm having a hard time figuring out if I should run the fetchJSON in the controller file or the cell file. Just need to override the var imageView = UIImageView(image: xxx) with cell.imageView.sd_setImage(with: url, completed: nil) from my json file to load the images. I'm close, but stuck on this part :\ Hope this makes sense, thanks for your help! I'm using import SDWebImage for the fetchJSON()
gottaminute
5 years ago
I think I got it... guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as? NewImageCell else { fatalError("Wrong cell class dequeued") } I added the guard to the cell and it's working now :) What's the best way to have the cell go to a url in a browser when clicked? The URL I want it to go to is, course.link . Thanks again!!!
Brian Voong
5 years ago
jiarongkoh
5 years ago
Hi Brian, I noticed that if the image heightAnchor isn't constraint, the clipsToBounds method for the imageView wouldn't work in a stackView. That would result in the image spilling out of the imageView. Is there a way to leverage on stackView to still clip the image while having the advantage of the two labels adopting their intrinsicContentSize?
Brian Voong
5 years ago
HELP & SUPPORT