AsyncImageView icon indicating copy to clipboard operation
AsyncImageView copied to clipboard

Clearing images with crossfadeImages = YES

Open banaslee opened this issue 11 years ago • 3 comments

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];
}

banaslee avatar Jul 02 '13 14:07 banaslee

I encountered the same problem.

72lions avatar Oct 16 '13 19:10 72lions

Are you still seeing this in 5.1?

nicklockwood avatar Jan 03 '14 09:01 nicklockwood

I am also facing the same problem. Any solution yet @nicklockwood ?

puneetchd avatar Mar 12 '14 06:03 puneetchd