Allren
Allren

Reputation: 11

How to startAnimating the .gif every cell in the tableView?

When I choose a cell in the tableview, the animation of .gif is stoped. how to solve it,who can give me some suggestion?

Upvotes: 0

Views: 1361

Answers (3)

rob mayoff
rob mayoff

Reputation: 385890

UIImage doesn't have built-in support for animated GIFs, but it's pretty easy to use the Image I/O framework to load them.

Image I/O Programming Guide
Image I/O Reference Collection

I have sample code that creates an animated UIImage from an animated GIF on github:

https://github.com/mayoff/uiimage-from-animated-gif

Upvotes: 0

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73668

iOS does not support gif animaiton. You'll have to do it like so -

-(void)startImageViewAnimation
{
NSArray *animationImages = [NSarray arrayWithObjects:[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],nil];

UIImageView *imageView = [UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
imageView.animationImages = animationImages ;
imageView.animationRepeatCount = 2;
imageView.animationDuration= 4.0;
[imageView startAnimating];

[NSTimer scheduledTimerWithTimeInterval:4.0 target:self
selector:@Selector(animationDone:)
userInfo:nil repeats:NO];
} 

-(void)animationDone:(NSTimer*)inTimer
{
[inTimer invalidate];
inTimer = nil;
NSLog(@"animationDone ");
}

Upvotes: 2

Jacob
Jacob

Reputation: 1459

As far as i know the iPhone SDK doesnt do .gifs you have to to do the animation yourself via UIView

Upvotes: 0

Related Questions