Iphone UIImageView动画在设备上具有长延迟

Iphone UIImageView动画在设备上具有长延迟,iphone,animation,uiimageview,Iphone,Animation,Uiimageview,我在UImageView上创建了一个5帧动画,每个图像都是由[UIImage imageWithContentOfFile:xxx]创建的, 然而,模拟器上的动画工作正常,但在设备上不工作,虽然动画持续时间为1秒,但通常有1秒的延迟 这是我的密码 NSArray *animations = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:@"ShakeAnimation"]; UIImageView *imgVi

我在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]

是否仍要预加载动画中涉及的图像?谢谢

我想出来了

如果要预加载
UIImageView
动画图像,只需在初始化后调用
[imgView startAnimating]
。这似乎对我有用。

我明白了


如果要预加载
UIImageView
动画图像,只需在初始化后调用
[imgView startAnimating]
。这似乎对我有用。

请显示将图像传递到imageview进行动画处理的代码,以及图像文件的来源?文件系统或类似Web的东西?!请显示您将图像传递到imageview进行动画处理的代码,以及图像文件的来源?文件系统或类似Web的东西?!只需提及-实际函数是startAnimating而不是startAnimation。只需提及-实际函数是startAnimating而不是startAnimation。