I have a Table View which displays images using lazy loading from AFNetworking with a placeholder image. I'm trying to accomplish a way to fade from the placeholder to the image when it's loaded. My code here works, but if an image loads while scrolling the table, everything looks odd and the table stops scrolling. Same thing happens to a Horizontal scroller with the same effect.
Here's the code I'm using inside cellForRowAtIndexPath
[cell.hotelImage setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:hotelImageUrl]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
success:^(NSURLRequest *request , NSHTTPURLResponse *response , UIImage *image ){
if (request) {
//Fade animation
[UIView transitionWithView:self.view
duration:1.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[cell.hotelImage setImage:image];
} completion:NULL];
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
}
];
I'm using the if(request) to avoid the animation once the image is in the cache.
Many thanks in advance.