Hi Brian,
I'm getting this crash error and not sure of the proper way to fix it...
UICollectionView received layout attributes for a cell with an index path that does not exist:
It happens when I scroll up and down on the collectionView.
Here is my code...
func setupViewControllers() {
let layout = UICollectionViewFlowLayout()
//let layoutTwo = UIViewController()
let newController = NewController(collectionViewLayout: layout)
let popController = PopularController(collectionViewLayout: layout)
// let aboutController = AboutController(collectionViewLayout: layoutTwo)
viewControllers = [
generateNavigationController(with: newController, title: "New Images", image: image(resourceName: "new")),
generateNavigationController(with: popController, title: "Popular Images", image: image(resourceName: "popular")),
generateNavigationController(with: AboutController(), title: "About", image: image(resourceName: "about"))
]
}
I'm using two (collectionViewLayout: layout) for two different screens. Do you happen to know what is causing this error?
Seems like the two collectionViews are getting confused with each other, but not sure :\
Thanks for any help!!
Hi,
I changed the code to this...
func setupViewControllers() {
let layoutNew = UICollectionViewFlowLayout()
let layoutPop = UICollectionViewFlowLayout()
//let layoutTwo = UIViewController()
let newController = NewController(collectionViewLayout: layoutNew)
let popController = PopularController(collectionViewLayout: layoutPop)
// let aboutController = AboutController(collectionViewLayout: layoutTwo)
viewControllers = [
generateNavigationController(with: newController, title: "New Images", image: #imageLiteral(resourceName: "new")),
generateNavigationController(with: popController, title: "Popular Images", image: #imageLiteral(resourceName: "popular")),
generateNavigationController(with: AboutController(), title: "About", image: #imageLiteral(resourceName: "about"))
]
}
So far no errors, but does that look like the correct fix? I separated the UICollectionViewFlowLayouts to have a unique name for each.