Ipad的动画图像崩溃问题
问题描述:
我在我所采取的ImageView作为背景,并在ImageView的我使用89个图像作出animation.Here是我的代码做动画Ipad的动画图像崩溃问题
-(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.What在ipad上实际发生的是有时它会闪烁,一段时间一次disappear.So请帮我出这个friends.I我也在-(void)viewWillDisappear
上发布了这个数组e朋友帮助我与它任何帮助或建议将不胜感激。
答
您的应用程序崩溃,因为BackGrdImage你释放后阵动画只有一次
[arrayOfImages removeAllObjects]
和
BackGrdImage.animationRepeatCount = 3;
由于这个原因您的图片第二次进行了动画制作,但BackGrdImage没有获得动画的arrayOfImages,因此您的应用程序会崩溃。
有一种方法,当你的图像动画三次意味着在1.5秒内,然后你必须调用一种方法释放arrayOfImages。 上述过程肯定会奏效。
答
您可能正在收到内存警告。因为我不认为该设备将支持89图像/图像浏览的图像数组。尝试在设备上调试您的应用。
可能不是问题,但请确保您在viewWillAppear:方法的某个时刻调用[super viewWillAppear:animated]。 – Sam 2011-04-27 06:31:11