Reused cells in a UICollectionView show multiple UIImageViews when they should only show one

后端 未结 7 1864
天命终不由人
天命终不由人 2020-12-08 09:53

Im having a problem with my UICollectionView. Initially it displays fine, showing a grid of cells, each cell with a single UIImageView. These

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 10:49

    For anyone who is adding UICollectionView programmatically and have a custom cell, in other words no XIB file, then you have to add this line to viewDidLoad

    [_collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
    

提交回复
热议问题