'Inheritance from non-protocol type 'UICollectionViewFlowLayout'
I have a horizontal collection view in my project which has 2 elements - a button and a label. Button and label are stuck to each other and then I want to show other button and label within the cell with space between 2 elements i.e. Button 1 and label 1, then some space and then display button 2 and label 2. Want to have some space between label 1 and button 2.
I came across some 'UICollectionViewFlowLayout' related methods and did try adding the code for it to test, but the functions are not getting called. Below are the functions:
extension MyController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 50
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 100
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 100, bottom: 100, right: 100)
}
}
However adding 'UICollectionViewFlowLayout' is giving me "Inheritance from non-protocol type 'UICollectionViewFlowLayout'"
error.
How can I get 'minimumLineSpacingForSectionAt' and other methods executed? Or how can I add space between label 1 and button 2, and then space between label 2 and button 3?
Solution 1:[1]
It is UICollectionViewDelegateFlowLayout
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sai Hari Krishnan |