cellForItemAt indexPath does not call if I'm using UICollectionViewDelegateFlowLayout.
In this case:
class Something: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
}
it calls my cellforItemAtIndexPath, but does not call my
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
}
but if I include UICollectionViewDelegateFlowLayout:
class Something: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
}
it will call:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
}
but will not call cellForItemAtIndexPath. I do not understand the problem. Is that a bug of iOS or I do not see anything?
For me, when creating the collectionView with layout, it should be let layout = UICollectionViewFlowLayout(), not let layout = UICollectionViewLayout() which is so easy to neglect. I was trapped in this like more than twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With