Fade animation UITableViewCell

Posted by Tomas on Stack Overflow See other posts from Stack Overflow or by Tomas
Published on 2011-03-09T16:01:01Z Indexed on 2011/03/09 16:10 UTC
Read the original article Hit count: 266

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about animation