Using the code below I have successfully made my UIImageView fade in its image.
[UIView transitionWithView:myCell.myImageView duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
myCell.myImageView.image = myImage;
} completion:NULL];
However, when the cell is reused I need to remove this image. When reused it shows the last image(shown before it was reused) and then transitions into the image it is supposed to be, instead of transitioning from no image into the image it is supposed to be.
What I have tried:
-(void)prepareForReuse {
[super prepareForReuse];
// More is obviously needed than just setting image to nil when using a transition
self.myImageView.image = nil;
[self.myImageView setNeedsDisplay];
// but I also tried removing all animations
[self.myImageView.layer removeAllAnimations];
// and I even tried removing the sublayers, but still no success.
[self.myImageView.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
}
Any help is appreciated, but please don't answer if you don't understand what the issue is. Comment instead so I can explain better if needed.
Thanks!
You could make use of the callback
tableView:didEndDisplayingCell:forRowAtIndexPath:
This is called is just as the cell goes outside the visible area.
Try setting the image to nil or no image over here. Should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With