UICollectionView + SDWebImage + Cell reuse

前端 未结 5 586
再見小時候
再見小時候 2021-01-06 03:39

I have a UICollectionView with a custom UICollectionViewCell class which adds another UIView (thumbnailView) to its contentView. This other view has a UIImageView property (

5条回答
  •  一向
    一向 (楼主)
    2021-01-06 04:14

    If I understand your problem correctly, you are getting old images still appearing in reused cells so in addition to stopping the previous image load you probably want to remove the old image from the imageView. SDImageView might have a method to clear the image or else you could just manually replace it with a placeholder image.

    - (void)prepareForReuse
    {
        [super prepareForReuse];
        [self.thumbnailView.imageView cancelCurrentImageLoad];
        [self.thumbnailView.imageView setImage:<> forState:UIControlStateNormal];
    }
    

提交回复
热议问题