| Statement You are welcome to repost this article, but please respect the author's Labor achievements. repost this article and keep the statement in this box. Thank you. ArticleSource: http://blog.csdn.net/iukey |
I. Pending
When a phone call comes in or locks the screen, your application will be suspended. At this time, the uiapplicationdelegate delegate will receive a notification and call the applicationwillresignactive method. You can rewrite this method to do the work before suspension, for example, disable the network and save data.
-(Void) applicationwillresignactive :( uiapplication *) Application {/* add your own pending preparationsCode*/}
When yourProgramIt will not run in the background after being suspended.
Ii. Restoration
When the program is restored, another method named applicationdidbecomeactive is called. You can restore your application by using the data saved before suspension:
-(Void) applicationdidbecomeactive :( uiapplication *) Application {/* add your recovery Code */}
Note: When an application is started, the applicationdidfinishlaunching method will also be called after the applicationdidbecomeactive method is called. Therefore, make sure that your code can distinguish recovery and startup to avoid logical bugs.
Iii. Termination
When you press the button or shut down, the program will be terminated. The applicationwillterminate method is called when a program is about to terminate normally. However, if the long master button is forced to exit, this method is not called. This method should be used to execute the remaining cleanup work. For example, all connections can be closed normally and any other necessary work should be executed before the program exits:
-(Void) applicationwillterminate :( uiapplication *) Application {/* Add the cleanup code and other work code before exiting here */}