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

后端 未结 7 1843
天命终不由人
天命终不由人 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:36

    Right after

    UICollectionViewCell * cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    

    Just add this line,

    [[[cell contentView] subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
    

提交回复
热议问题