UIImageView in custom UICollectionViewCell returning nil all the time

后端 未结 5 1831
既然无缘
既然无缘 2020-12-29 05:02

OK in my story board I have made a UICollectionView with 3 cells. One of the cells I made a custom class for that obviously extends the UICollectionViewCell:

5条回答
  •  长发绾君心
    2020-12-29 05:39

    You should register the custom cell's nib if you are using one like this-

    So it will be:

    [self.collectionView registerNib:[UINib nibWithNibName:@"CustomCell" bundle:nil] forCellWithReuseIdentifier:@"CustomCellIdentifier"];
    

    instead of:

    [self.collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:@"CustomCellIdentifier"];
    

提交回复
热议问题