简体   繁体   中英

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

I created an iPhone app with XCode and Phonegap.

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.

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.361 [810:907] --- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate myFunc]: unrecognized selector sent to instance 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)

libc++abi.dylib: terminate called throwing an exception

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.

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.

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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