views:

53

answers:

0

Hi,

I'm using a ABTableViewCell subclass ( http://github.com/enormego/ABTableViewCell ) as cells of a UITableView. This improves scrolling smoothness a lot as cells have many elements including pictures, but I can't find how to create animations for a single element of a cell.

For example, when a image is loaded from the web, I'd like to make it appear in a short animation raising its alpha from 0 to 1. I have no trouble creating the animation for the whole cell's alpha, by doing this:

 // self = ResultTableViewCell, inherits from ABTableViewCell

 // Method called by the class loading the image asynchronously
 (void)setImage:(UIImage *)i {
 [image release];
 if (i != nil)
  image = [[UIImage imageWithCGImage:[i CGImage]] retain];
 else
  image = nil;

 self.alpha = 0.0;
 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:0.3];
 self.alpha = 1.0;
 [UIView commitAnimations];
 [self setNeedsDisplay];
}

But this obviously makes the whole cell disappear then gradually reappear. As self.image is not a UIImageView but a UIImage I draw manually in drawContentView:, I can't set its own alpha value for the animation.

I tried adding a class property for the UIImage's alpha, putting it in place of self.alpha in the code above, and use it in drawContentView by calling drawInRect: blendMode: alpha: for the image. But whatever handles animations doesn't make neither successive calls to the image's alpha setter nor to drawContentView (which would have been a bit rough), so this has no effect.

What would be the solution?