简体   繁体   中英

Save the application state when it has been deleted from the background

I am using following functions in my App delegate

- (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"applicationWillResignActive");

}


- (void)applicationDidEnterBackground:(UIApplication *)application {

    NSLog(@"applicationDidEnterBackground");

}


- (void)applicationWillEnterForeground:(UIApplication *)application {
     NSLog(@"applicationWillEnterForeground");

}


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

      NSLog(@"applicationDidBecomeActive");

}


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

}

All functions are working fine. But When i Delete the app from the Background by clicking "-" red button in the background tasks, and again open the app. no function has been called. What should i use instead of all the above functions..have any ideas?

What exactly i need is ..i need to save the application state when it has been deleted from the background using "-" red button and restore it when ever it opened.

You should save the state of the application when it enters background mode ( -applicationDidEnterBackground ). No delegate methods are called when a background app is terminated.

You should find a lot of useful informations about this in the iOS Application Programming Guide .

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