CollectionView sizeForItemAtIndexPath never called

前端 未结 15 1278
一整个雨季
一整个雨季 2020-12-24 11:17

This is driving me crazy! I have a UICollectionViewController as shown below:

class PhrasesCompactCollectionViewController: UICollectionViewController
         


        
15条回答
  •  醉梦人生
    2020-12-24 12:04

    For me (in Swift 3.1) the method must be declared public like this:

        public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
           return CGSize()
        }
    

    Don't forget to make it public.

提交回复
热议问题