【发布时间】:2010-05-24 03:21:28
【问题描述】:
我在 UImageView 上创建了一个 5 帧动画,每个图像都是由 [UIImage imageWithContentOfFile:xxx] 创建的, 然而,模拟器上的动画效果很好,但在设备上却不行,虽然动画持续时间是 1 秒,但它通常有大约 1 秒的延迟。
这是我的代码。
NSArray *animations = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:@"ShakeAnimation"];
UIImageView *imgView = [[UIImageView alloc]initWithImage:[UIImage imageWithContentsOfFile:[animations objectAtIndex:0]]];
imgView.tag = 10;
NSMutableArray *animationImgs = [[NSMutableArray alloc] init];
for( NSString *path in animations )
{
[animationImgs addObject:[UIImage imageWithContentsOfFile:path]];
}
[imgView setAnimationRepeatCount:2];
[imgView setAnimationImages:animationImgs];
[imgView setAnimationDuration:1];
[animationImgs release];
当视图控制器收到 shack 事件时,它会调用 [imgView startAnimation];
无论如何要预加载动画中涉及的图像?谢谢。
【问题讨论】:
-
请显示您将图像传递给 imageview 以进行动画处理的代码
-
您的图像文件的来源是什么?文件系统或类似 Web 的东西?!
标签: iphone animation uiimageview