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

后端 未结 2 1708
忘了有多久
忘了有多久 2020-12-21 08:26

I\'m new to UICollectionView and I\'m following a tutorial that I found on Youtube, but i\'m stuck on an error I can\'t figure out.

When I run the app w

2条回答
  •  时光取名叫无心
    2020-12-21 09:25

    Register Collection cell in viewDidLoad method ::

    [self.collView registerClass:[mineCell class] forCellWithReuseIdentifier:@"cvCell"];
    

    Try this after above line:

    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    [flow setItemSize:CGSizeMake(60, 60)];
    [flow setScrollDirection:UICollectionViewScrollDirectionVertical];
    
    [self.collView setCollectionViewLayout:flow];
    

    Here, mineCell is my custom collectionViewCell or you can use [UICollectionViewCell class]directly.

    Thanks.

提交回复
热议问题