【问题标题】:UIImageView animation has long delay on deviceUIImageView 动画在设备上有很长的延迟
【发布时间】: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


【解决方案1】:

我想通了!

如果要预加载UIImageView动画图片,初始化后调用[imgView startAnimating]即可。它似乎对我有用。

【讨论】:

  • 顺便提一下 - 实际功能是 startAnimating 而不是 startAnimation。
猜你喜欢
  • 1970-01-01
  • 2012-02-08
  • 2023-04-05
  • 2015-02-20
  • 1970-01-01
  • 1970-01-01
  • 2015-03-16
  • 2014-08-03
  • 2017-01-23
相关资源
最近更新 更多