开发者

UIImageView animation has long delay on device

I create a 5-frame animation on UImageView and each image is created by [UIImage imageWithContentOfFile:xxx], however, the animation on simulator is working well but not on device, it usually has ~1 sec delay though the animation duration is 1sec.

This is my code.

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];

and when the view controller recieved shack event, it calls [开发者_JAVA技巧imgView startAnimation];

Is anyway to preload the images involved in the animation? thanks.


I figured it out!

If you want to preload the UIImageView animation images, just call [imgView startAnimating] after initialization. It seemed to work for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜