Reputation: 2797
swift3
I need to use some optional
methods of UICollectionViewDelegateFlowLayout
, however method below is never called.
insetForSectionAt
optional public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets
Since UICollectionViewDelegateFlowLayout
inherited from UICollectionViewDelegate
- all I need to do is to assign collection'sView
delegate:
self.collectionView.delegate = self.delegate
Note that everything else works fine and methods like sizeForItem
or cellForItem
gets called.
Upvotes: 2
Views: 891
Reputation: 2216
Please make sure if you have implemented UICollectionViewDelegateFlowLayout in your class like this:
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
//...your code here
}
Upvotes: 1