Recently, an app for iPhone 4.0 OS encountered a home key about exiting the background.Program. I drew some effort and finally found a simple solution to the extreme. Share it here. Because of the multi-task support in the iPhone 4.0 OS, you can press and hold the Home key while running the program. Instead, you can transfer the program to the background. When the program starts again, it continues to run last time, therefore, for some programs, we need to take measures to ensure that the program is cleared from the memory after the home key is pressed. So that at the next entry, the program is restarted, rather than running. The following is a solution to this problem. If you do not need to store any data, you can directly process it as follows.
The solution is to use the-(void) applicationdidenterbackground :( uiapplication *) application method in the uiapplicationdelegate proxy. You only need to execute the exit (0) operation in it.
-(Void) applicationdidenterbackground :( uiapplication *) Application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationwillterminate: when the user quits.
*/
Exit (0 );
}
Supplement: although the text has been written for some days, I still want to make some supplements here, recently, it was discovered that in addition to the preceding method, you can add an application does not run in background in the XXX-info.plist (XXX is the project name) and check back the checkbox. That's all.