Fade animation UITableViewCell
- by Tomas
Hi everyone,
I have a UITableViewController that populates a UITableView with some data that I pull off the net. The data for each cell consists also of an image used as background, which I'm downloading in a separated NSOperation added to a NSOperationQueue with a MaxConcurrentOperationCount set to 4. As long as the image is not downloaded I'm showing a generic placeholder which I would like to replace (fading out/fading in) with the downloaded image once it's being successfully downloaded.
I'm using the following code placed inside the cellForRowAtIndexPath of the UITableViewController.
[UIView beginAnimations:@"fade" context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:3.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
cell.placeholderUIImage.alpha = 0.0;
cell.backgroundUIImage.alpha = 1.0;
[UIView commitAnimations];
This is unfortunately just working randomly for a couple of rows, since for the most the background image is set instantly, as if the animation started on one cell would have been "overwritten" by the next call of beginAnimations.