在我看来,我有一个按钮,它与此方法挂钩:
-(IBAction)showStore:(id)sender
{
storeSinglePlayer *ssp = [[storeSinglePlayer alloc] init];
ssp.imageH = self.imageURLH;
ssp.imageV = self.imageURLV;
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:ssp animated:NO];
}
当我单击此按钮时,它会显示“存储单人游戏”视图控制器。此外,“存储单人游戏”视图控制器有一个后退按钮,该按钮与以下方法挂钩:
-(IBAction)didPressBack:(id)sender
{
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
}
单击后退按钮也会让我回到以前的视图。
但现在这是一个奇怪的问题。如果我重复这 10 次,即单击按钮显示“storeSinglePlayer”,然后单击“storeSinglePlayer”上的后退按钮,我会收到错误消息:
[storeSinglePlayer respondsToSelector:]: message sent to deallocated instance 0xe5f6160
而且,这不仅在我的多次尝试中,而且只是随机崩溃。它会工作一段时间,有时不会。
我启用了 ARC。
仅仅这个简单的代码就无法理解有什么问题。阅读了很多关于堆栈溢出的问题,但没有一个能解决我的问题。
编辑:堆栈跟踪
2012-08-11 11:55:56.353 Magic Buzz[2088:707] (
0 Magic Buzz 0x000c7e19 -[gameOverScreen showStore:] + 700
1 CoreFoundation 0x3769c3fd -[NSObject performSelector:withObject:withObject:] + 52
2 UIKit 0x30891e07 -[UIApplication sendAction:to:from:forEvent:] + 62
3 UIKit 0x30891dc3 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4 UIKit 0x30891da1 -[UIControl sendAction:to:forEvent:] + 44
5 UIKit 0x30891b11 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 492
6 UIKit 0x30892449 -[UIControl touchesEnded:withEvent:] + 476
7 UIKit 0x3089092b -[UIWindow _sendTouchesForEvent:] + 318
8 UIKit 0x30890319 -[UIWindow sendEvent:] + 380
9 UIKit 0x30876695 -[UIApplication sendEvent:] + 356
10 UIKit 0x30875f3b _UIApplicationHandleEvent + 5826
11 GraphicsServices 0x3789222b PurpleEventCallback + 882
12 CoreFoundation 0x37716523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
13 CoreFoundation 0x377164c5 __CFRunLoopDoSource1 + 140
14 CoreFoundation 0x37715313 __CFRunLoopRun + 1370
15 CoreFoundation 0x376984a5 CFRunLoopRunSpecific + 300
16 CoreFoundation 0x3769836d CFRunLoopRunInMode + 104
17 GraphicsServices 0x37891439 GSEventRunModal + 136
18 UIKit 0x308a4cd5 UIApplicationMain + 1080
19 Magic Buzz 0x000b094d main + 96
20 Magic Buzz 0x000b08e8 start + 40
)
2012-08-11 11:55:56.554 Magic Buzz[2088:707] *** -[storeSinglePlayer respondsToSelector:]: message sent to deallocated instance 0xf6cde30