UICollectionView: must be initialized with a non-nil layout parameter

后端 未结 7 2200
不思量自难忘°
不思量自难忘° 2020-11-27 05:25

I added UICollectionView by code.
Now, the app crash with message: UICollectionView must be initialized with a non-nil layout parameter.
Do

7条回答
  •  无人及你
    2020-11-27 06:25

    don't setCollectionViewLayout liked this:

    [self.collectionView setCollectionViewLayout:flowLayout];
    

    try to set when init:

    [[UICollectionView alloc] initWithFrame:frame collectionViewLayout:defaultLayout];
    

提交回复
热议问题