Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animated GIF does not work on iPhone

I am using cell.image = an animated gif file (cell is UITableViewCell). However, it does not animate. Is there any way I can fix it?

like image 254
ebaccount Avatar asked Jun 10 '09 00:06

ebaccount


1 Answers

UIImageView provides the necessary APIs to produce your own animations like this:

UIImage *frame1 = [UIImage imageNamed:@"frame1.png"];
UIImage *frame2 = [UIImage imageNamed:@"frame2.png"];
UIImage *frame3 = [UIImage imageNamed:@"frame3.png"];
UIImage *frame4 = [UIImage imageNamed:@"frame4.png"];


UIImageView.animationImages = [[NSArray alloc] initWithObjects:frame1, frame2, frame3, frame4, nil];
UIImageView.animationDuration = 1.0 //defaults is number of animation images * 1/30th of a second
UIImageView.animationRepeatCount = 5; //default is 0, which repeats indefinitely
[UIImageView startAnimating];

//[uiImageView stopAnimating];
like image 136
Nathan de Vries Avatar answered Sep 19 '22 12:09

Nathan de Vries