【发布时间】:2011-04-27 05:33:38
【问题描述】:
我有一个应用程序,其中我将 imageview 作为背景,在该 imageview 中我使用 89 个图像来制作动画。这是我制作动画的代码
-(void)viewWillAppear:(BOOL)animated
{
NSString *cachesDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSLog(@"cachesDirectoryPath: %@", cachesDirectoryPath);
CPIAppDelegate *obj=(CPIAppDelegate *)[[UIApplication sharedApplication]delegate];
arrayOfImages=[[NSMutableArray alloc]init];
viewMenu.hidden = obj.buttonStatus;
for (int i=0; i<IMAGE_ANIMATION_COUNT; i++) {
// [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/streamvideo351_frame%d.jpg",cachesDirectoryPath,i]];
[arrayOfImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"streamvideo351_frame%d.jpg",i]]];
}
BackGrdImage.animationImages=arrayOfImages;
BackGrdImage.animationDuration =5.0;
BackGrdImage.animationRepeatCount =3;
[BackGrdImage startAnimating];
[arrayOfImages removeAllObjects];
}
在我正在使用的 dealloc 方法中
[imageAnimations release];
[BackGrdImage removeFromSuperview];
[BackGrdImage release];
它在模拟器上运行良好但在 Ipad 上崩溃。ipad 中实际发生的情况是有时它会闪烁,有时它会消失。所以请帮我解决这个问题。我也在 -(void)viewWillDisappear 上发布数组所以请朋友帮我解决一下。任何帮助或建议将不胜感激。
【问题讨论】:
-
可能不是问题,但请确保在 viewWillAppear: 方法的某个时间点调用 [super viewWillAppear:animated]。
标签: iphone objective-c ios4 animation