之前我有过这个问题,尝试过回答,但仍然没有用。
在我分配之前:
imageArray_danceright = [[NSArray alloc] initWithObjects:
我被告知要像波纹管那样做,但现在它在第二次动画之后立即崩溃:
//init areas:
imageArray_stand = [NSArray arrayWithObjects:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankieSingtRetime_0001" ofType:@"jpg"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankieSingtRetime_0002" ofType:@"jpg"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankiePeaceRetime_0003" ofType:@"jpg"]],nil];
imageArray_danceleft = [NSArray arrayWithObjects:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankiePeaceRetime_0001" ofType:@"jpg"]],
.. 40 images
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankiePeaceRetime_0040" ofType:@"jpg"]],nil];
imageArray_danceright = [NSArray arrayWithObjects:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankiePeaceRetime_0041" ofType:@"jpg"]],
.. 40 images
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FrankiePeaceRetime_0080" ofType:@"jpg"]],nil];
//start:
[myimageview setAnimationImages:imageArray_stand];
myimageview.animationDuration = 0.23;
myimageview.contentMode = UIViewContentModeBottomLeft;
myimageview.animationRepeatCount = 0.0;
myimageview.image = [myimageview.animationImages objectAtIndex:1];
[myimageview startAnimating];
// ------ in my 'touchesBegan" i have:
if ([touch view] == overlay_fuesserechts) {
[myimageview.animationImages release];
[myimageview setAnimationImages:imageArray_danceright];
myimageview.animationDuration = 2.0;
myimageview.contentMode = UIViewContentModeBottomLeft;
myimageview.animationRepeatCount = 0;
[myimageview startAnimating];
}
- (void)dealloc {
[imageArray_stand release];
imageArray_stand=nil;
[imageArray_danceright release];
imageArray_danceright=nil;
[imageArray_danceleft release];
imageArray_danceleft=nil;
super dealloc];
}
它以“立场”动画开始..但当我触发触摸时,它立即崩溃:
[myimageview setAnimationImages:imageArray_danceright];
我不知道。我尝试了很多东西。现在我希望你有个主意。
THX 克里斯
答案 0 :(得分:0)
你肯定不需要在触摸开始时[myimageview.animationImages release];
开始。您正在创建自动释放的数组对象,并将它们分配给将要释放它们的imageview。
答案 1 :(得分:0)
因为您要自动释放图像数组,所以当它到达TouchesBegan时,它们已经被释放了。
谁告诉您使用arrayWithObjects
代替alloc
- initWithObjects
?
听起来你的早期版本会更正确。你遇到的问题是什么?