I'm trying to animate an image in a UITableViewCell subclass. It works when the tap on the cell is about 1/2 second or more in duration. For shorter taps, the cell gets selected, but my animation doesn't run.
In my view controller, I have:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ImageCell *cell = (ImageCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.imageFlashDuration = 5.0;
cell.imageFlashNumberOfFrames = 25;
NSLog(@"Flash image...");
[cell flashImage];
[self performSelector:@selector(doSomething:) withObject:video afterDelay:5.0];
}
In my ImageCell:
-(void)flashImage {
UIImage *image = imageView.image;
if(imageView.isAnimating) {
NSLog(@"Stop animating");
[imageView stopAnimating];
}
NSMutableArray *animationArray = [NSMutableArray arrayWithCapacity:imageFlashNumberOfFrames];
for(int i=0; i<imageFlashNumberOfFrames; i++) {
[animationArray addObject:(i % 2 == 0? black60x60Image : image)];
}
imageView.animationImages = animationArray;
imageView.animationDuration = imageFlashDuration;
NSLog(@"> Start animating");
[imageView startAnimating];
}
In my log, I see
2009-07-02 22:02:55.907 MyProg[1797:20b] Flash image...
2009-07-02 22:02:55.912 MyProg[1797:20b] > Start animating
2009-07-02 22:02:59.455 MyProg[1797:20b] Flash image...
2009-07-02 22:02:59.460 MyProg[1797:20b] > Start animating
2009-07-02 22:03:02.463 MyProg[1797:20b] Flash image...
2009-07-02 22:03:02.468 MyProg[1797:20b] > Start animating
2009-07-02 22:03:05.009 MyProg[1797:20b] Flash image...
2009-07-02 22:03:05.014 MyProg[1797:20b] > Start animating
The above was from a mixture of 'short' and 'long' touches. The long touches resulted in cell selection and image animation and the short ones resulted in cell selection without animation.
Additionally, if a short tap is followed by another short tap on the cell, the animation begins.