Learn about the most important components of collection views; the controller, the layout, and the data source.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3819-beginning-collection-views/lessons/2
Learn about the most important components of collection views; the controller, the layout, and the data source.
Where can I find the starter project for lesson 2?
The materials have been updated to include the sample projects. Thanks for bringing this to our attention! :]
Michael, do you happen to have the swift 2.2 version of this code?
(I need to make it work in 7.3.1)
I converted most of it however, I am having trouble in understanding what I should be changing in PerksDataSource.swift.
It wonโt recognize IndexPath as a type.
Instead IndexSize you need to use (in MasterViewController.swift):
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) โ CGSize {
let width = view.frame.width/3
return CGSize(width: width, height: width)
}
And class MasterViewController will look like this:
class MasterViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout{
}
Instead IndexSize you need to use (in MasterViewController.swift):
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) โ CGSize {
let width = view.frame.width/3
return CGSize(width: width, height: width)
}
And class MasterViewController will look like this:
class MasterViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout{
}
Hey everyone was just wondering if you have the swift 3 version of this code? I am getting errors in my MasterViewCollection file. Around the step at 5:58 in part 2 video. See dropbox link: Dropbox - Screen Shot 2017-03-17 at 1.53.42 pm.png - Simplify your life
Thank you so much for your help!!
Hi,
I think you need to add โreturn cellโ~~
This error means that you need return UICollectionViewCell for this function.
cell.textLabel does not exist for collection view cells.
@skyrocketsw Can you please help with this when you get a chance? Thank you - much appreciated! :]