I have a UICollectionView with a custom UICollectionViewCell class which adds another UIView (thumbnailView) to its contentView. This other view has a UIImageView property (imageView) whose image gets loaded with SDWebImage asynchronously. This all works fine until the cell is reused while the image of the original cell is still being loaded. If you scroll fast enough through the CollectionView images start to pop up in cells where they are not supposed to be (probably because the cell got reused and the image download finishes afterwards), just to get replaced as soon as the correct image for the reused cell finishes loading.
To fix this, I added the following to my UICollectionViewCell subclass to stop the original cell's image download:
- (void)prepareForReuse
{
[super prepareForReuse];
[self.thumbnailView.imageView cancelCurrentImageLoad];
}
But to my surprise, this seems to change absolutely nothing. Am I doing something wrong or am I just looking in the wrong direction?