【发布时间】:2011-10-27 02:38:37
【问题描述】:
当我在 tableview 中选择一个单元格时,.gif 的动画会停止。怎么解决,谁能给点建议?
【问题讨论】:
标签: iphone objective-c ios tableview gif
当我在 tableview 中选择一个单元格时,.gif 的动画会停止。怎么解决,谁能给点建议?
【问题讨论】:
标签: iphone objective-c ios tableview gif
iOS 不支持gif 动画。你必须这样做 -
-(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 ");
}
【讨论】:
据我所知 iPhone SDK 不做 .gifs 你必须通过 UIView 自己做动画
【讨论】:
UIImage 没有对动画 GIF 的内置支持,但使用 Image I/O 框架来加载它们非常容易。
Image I/O Programming Guide
Image I/O Reference Collection
我有从 github 上的动画 GIF 创建动画 UIImage 的示例代码:
【讨论】: