简体   繁体   English

为什么我的iPhone应用程序重新打开后会崩溃?

[英]Why does my iPhone app crash after re-opening it?

I created an iPhone app with XCode and Phonegap. 我用XCode和Phonegap创建了一个iPhone应用程序。

Launching the app works perfectly fine but when I press the home button of the iPhone (which puts the app into the background) and then open the app again (to bring it to foreground), it crashes. 启动该应用程序可以正常运行,但是当我按下iPhone的“主页”按钮(它将应用程序置于后台)然后再次打开该应用程序(使其进入前台)时,它崩溃了。

This is what the logs say: 这就是日志所说的:

2012-10-31 14:37:21.359 [810:907] -[AppDelegate myFunc]: unrecognized selector sent to instance 0x1e064220 2012-10-31 14:37:21.359 [810:907]-[AppDelegate myFunc]:无法识别的选择器已发送到实例0x1e064220

2012-10-31 14:37:21.361 [810:907] --- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate myFunc]: unrecognized selector sent to instance 0x1e064220' 2012-10-31 14:37:21.361 [810:907] ---由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[AppDelegate myFunc]:无法识别的选择器已发送至实例0x1e064220'

--- First throw call stack: ---第一个调用堆栈:

(0x361b62a3 0x344c697f 0x361b9e07 0x361b8531 0x3610ff68 0x36107037 0x33bc9d91 0x37630213 0x3762fdff 0x37487d61 0x374876d5 0x37487123 0x3663a5a3 0x3618b683 0x3618aee9 0x36189cb7 0x360fcebd 0x360fcd49 0x366392eb 0x374db301 0xe7c89 0xe7c20) (0x361b62a3 0x344c697f 0x361b9e07 0x361b8531 0x3610ff68 0x36107037 0x33bc9d91 0x37630213 0x3762fdff 0x37487d61 0x374876d5 0x37487123 0x3663a5a3 0x3618b374 0x3618e7dce 0x36018e7dce 0x3618b7e79x360x3d

libc++abi.dylib: terminate called throwing an exception libc ++ abi.dylib:终止调用引发异常

The image attached shows the line of code where it stops. 随附的图像显示了该行所在的代码行。 在此处输入图片说明

What's going on? 这是怎么回事?

It appears you're invoking a method called myFunc that doesn't exist on your AppDelegate. 看来您正在调用AppDelegate上不存在的名为myFunc的方法。

This will cause the application to terminate. 这将导致应用程序终止。 Check that function exists or remove the invokation. 检查功能是否存在或删除该调用。

When you bring an app from the background to the foreground, different methods are invoked on the delegate, so your call to MyFunc might exist there. 当您从后台将应用程序带到前台时,在委托上会调用不同的方法,因此您对MyFunc的调用可能在那里。

Check 校验

applicationDidBecomeActive

and

applicationWillEnterForeground

The details of this can be found here: 详细信息可以在这里找到:

http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

I might be wrong, did you add some logic in 我可能是错的,您是否在其中添加了一些逻辑

- (void)applicationWillEnterForeground:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application

And there is something you have released? 您发布了一些东西吗? And also did you check with this?-[AppDelegate myFunc] 您也检查过吗?-[AppDelegate myFunc]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM