Ios 终止NSException类型的未捕获异常
我的游戏在重启游戏后按下某个按钮后不断崩溃 游戏期间,动画始终在我运行游戏的ViewController中运行 这是坠机日志。有没有办法检测这次崩溃与我的动画有什么关系Ios 终止NSException类型的未捕获异常,ios,objective-c,calayer,nsexception,Ios,Objective C,Calayer,Nsexception,我的游戏在重启游戏后按下某个按钮后不断崩溃 游戏期间,动画始终在我运行游戏的ViewController中运行 这是坠机日志。有没有办法检测这次崩溃与我的动画有什么关系 2014-08-05 00:21:30.044 windmill[702:90b] -[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10 2014-08-05 00:21:30.053 windmill[702:90b] *** Term
2014-08-05 00:21:30.044 windmill[702:90b] -[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10
2014-08-05 00:21:30.053 windmill[702:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10'
*** First throw call stack:
(
0 CoreFoundation 0x01c501e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x019cf8e5 objc_exception_throw + 44
2 CoreFoundation 0x01ced243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01c4050b ___forwarding___ + 1019
4 CoreFoundation 0x01c400ee _CF_forwarding_prep_0 + 14
5 QuartzCore 0x0013b9b8 CAObject_setValueForKeyPath_ + 2435
6 QuartzCore 0x0012129b -[CALayer setValue:forKeyPath:] + 471
7 QuartzCore 0x00105d51 -[CABasicAnimation applyForTime:presentationObject:modelObject:] + 1178
8 QuartzCore 0x0012415c _ZN2CA5Layer18presentation_layerEPNS_11TransactionE + 494
9 QuartzCore 0x00127cbe -[CALayer presentationLayer] + 43
10 UIKit 0x006eb0f1 _UIViewEatsTouches + 142
11 UIKit 0x006eb250 -[UIView(Geometry) hitTest:withEvent:] + 114
12 UIKit 0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
13 CoreFoundation 0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
14 CoreFoundation 0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
15 UIKit 0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
16 UIKit 0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
17 CoreFoundation 0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
18 CoreFoundation 0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
19 UIKit 0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
20 UIKit 0x006daeb1 __54+[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:]_block_invoke + 175
21 UIKit 0x006dad1e +[UIWindow _topVisibleWindowPassingTest:] + 198
22 UIKit 0x006dadfa +[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:] + 176
23 UIKit 0x0068c5bb _UIApplicationHandleEventQueue + 7975
24 CoreFoundation 0x01bd977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x01bd910b __CFRunLoopDoSources0 + 235
26 CoreFoundation 0x01bf61ae __CFRunLoopRun + 910
27 CoreFoundation 0x01bf59d3 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x01bf57eb CFRunLoopRunInMode + 123
29 GraphicsServices 0x0341c5ee GSEventRunModal + 192
30 GraphicsServices 0x0341c42b GSEventRun + 104
31 UIKit 0x0068ff9b UIApplicationMain + 1225
32 windmill 0x00004afd main + 141
33 libdyld.dylib 0x03103725 start + 0
34 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
当我按下视图中的按钮时,应用程序崩溃。以下是动画代码:
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 4;
fullRotation.repeatCount= 1000;
[[stick layer] addAnimation:fullRotation forKey:@"60"];}
我很抱歉,如果代码被弄乱了,我仍然在学习和构建小型应用程序和游戏,以获得更好的实践。谢谢。您应该删除带有fullRotation.fromValue的线条,因为它不应该为自己指定CALayer
fullRotation.fromValue = self.view.layer.presentationLayer;
首先,您应该在传递此消息的任何地方找到-[CALayer doubleValue]:@EDUsta并不完全适用于此,因为这不应该发生。-doubleValue消息被无意地发送到CALayer。只需检查使用-doubleValue的位置,而不考虑上下文。@ChristianSchnorr你是对的,但我认为[CALayer setValue:forKeyPath:]是原因,而不是直接使用-doubleValue。@EDUsta在我所有的动画中,这是关键路径行:Cabasicanization*fullRotation=[CABasicAnimation animationWithKeyPath:@transform.rotation];我应该更改什么吗?我想我们应该在您按下该按钮时查看执行的代码。