AsyncImageView
AsyncImageView copied to clipboard
Clearing images with crossfadeImages = YES
I'm using AsyncImageView objects with reusable cells in a UICollectionView. To reuse the cell I have to reset the images by setting them to nil. However, when crossfadeImages property is set to YES the image won't be reset.
The workaround is to set crossfadeImages to NO before setting the image to nil and then setting it back to YES.
I tried to change the setImage method in the following way but it didn't work. I was expecting that the transition with a nil image was causing the behavior but actually it's not.
- (void)setImage:(UIImage *)image
{
if (_crossfadeImages && image)
{
//implement crossfade transition without needing to import QuartzCore
id animation = objc_msgSend(NSClassFromString(@"CATransition"), @selector(animation));
objc_msgSend(animation, @selector(setType:), @"kCATransitionFade");
objc_msgSend(animation, @selector(setDuration:), _crossfadeDuration);
objc_msgSend(self.layer, @selector(addAnimation:forKey:), animation, nil);
}
super.image = image;
[_activityView stopAnimating];
}
I encountered the same problem.
Are you still seeing this in 5.1?
I am also facing the same problem. Any solution yet @nicklockwood ?