sizeForItemAtIndexPath is not found in different swift versions

Vikram Biwal picture Vikram Biwal · Oct 14, 2016 · Viewed 11.7k times · Source

I am using UICollectionView but following method not found:

 func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize

please suggest me it's replacement.

Answer

Roland Keesom picture Roland Keesom · Dec 21, 2016

For me sizeForItemAt wasn't called because in Swift 3 you need to explicitly set your class to implement the UICollectionViewDelegateFlowLayout protocol