在我的 iPhone 应用程序的 viewDidLoad 方法中,我有以下代码:
zombie[i].animationImages = zombieImages;
zombie[i].animationDuration = 0.8/zombieSpeed[i];
zombie[i].animationRepeatCount = -1;
[zombie[i] startAnimating];
稍后在应用程序中调用以下代码:
[zombie[i] stopAnimating];
zombie[i] = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"zh.png"]];
zombie[i].animationImages = flyingZombieImages;
zombie[i].animationDuration = 0.8/zombieSpeed[i];
zombie[i].animationRepeatCount = -1;
[zombie[i] startAnimating];
这会导致应用程序崩溃,EXC_BAD_ACCESS 在线zombie[i].animationImages = flyingZombieImages;
flyingZombieImages
使用以下代码初始化:(zombieImages
以相同的方式初始化)
NSMutableArray *flyingZombieImages = [NSMutableArray array];
for (NSUInteger i=1; i <= 29; i++) {
NSString *imageName = [NSString stringWithFormat:@"flzom%d.png", i];
[flyingZombieImages addObject:[UIImage imageNamed:imageName]];
}
为什么会这样?有解决方法吗?