开发者

Using the applicationWillTerminate method doesn't seem to be working

开发者 https://www.devze.com 2023-01-22 08:46 出处:网络
I am wanting to save some app state data for when the user is quitting the app. I am thinking that I should be using the applicationWillTerminate method inside of my appDelegate, bu开发者_如何学编程t

I am wanting to save some app state data for when the user is quitting the app. I am thinking that I should be using the applicationWillTerminate method inside of my appDelegate, bu开发者_如何学编程t when I try and do anything there, it's not doing anything:

- (void) applicationWillTerminate:(UIApplication *)application {
NSLog(@"test");
 }

When I run my app, and do some stuff, and hit the home button to quit the app, nothing comes over the console...

Do I have to implement the applicationWillTerminate method in the appDelegate? The user of my app will most likely be in a Reader view when they leave, is there anyway to implement the app will close method there?


see this link iPhone simulator and applicationWillTerminate() for older iOS versions;

but remember the Home button does not necessarily terminate the application is ios4... you should use applicationDidEnterBackground but would suggest both places applicationWillTerminate and applicationDidEnterBackground

Adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES will make you application quit when you hit the home button, even on iOS4


In iOS 4, the applicationWillTerminate: method is only called if you opt out of the background execution model. In the standard iOS 4 application lifecycle, applications are suspended (not terminated) when the home button is pressed. Your application delegate will receive an applicationWillResignActive: message followed by an applicationDidEnterBackground: message. The applicationDidEnterBackground: method is a good place to save user data.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号