我有一个21帧的菜单背景的动画。我使用视图的viewDidLoad方法中的下面的代码将它们加载到内存中。UIImageView动画延迟做startAnimating时
NSMutableArray *menuanimationImages = [[NSMutableArray alloc] init];
for(int aniCount = 0; aniCount < 21; aniCount++)
{
NSString *fileLocation = [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"bg%i", aniCount + 1] ofType: @"png"];
NSData *imageData = [NSData dataWithContentsOfFile: fileLocation];
[menuanimationImages addObject: [UIImage imageWithData:imageData]];
}
settingsBackground.animationImages = menuanimationImages;
不幸的是,做[settingsBackground startAnimating];在viewDidLoad方法中不起作用。有没有预加载动画的方法,以便第一次运行时不会出现1-3秒的延迟?
非常感谢您的协助!伟大的代码! –
@DanielGillespie是否适合你?我也面临同样的问题。 – arundevma
完美工作 - 非常感谢! – 2013-02-03 17:17:58