When the iphone home button is pressed, it will only hide the user interface but any process currently running will keep on running at开发者_Python百科 the background. I find that if the process is still running, when i activate the app again, the splash screen will be displayed for a long time until the process is completes before it display the main page of the app. Is there a way to terminate the processes when the home button is pressed?
1) For example, if I have a for loop and before the loop finishes, the home button is pressed, is there a way to terminate the loop?
2) What if instead of a loop, its a delegate waiting for the sdk function to finish the process. eg. After calling UIImageWriteToSavedPhotosAlbum to save an image, didFinishSavingWithError will be called when it finish saving. Can i terminate the saving process whe the home button is pressed?
Thanks.
You can try adding a new row in the info.plist of your application and select "Application does not run in background" or write "UIApplicationExitsOnSuspend"
- Do as Aluminum said.
Not to do 1, but add the following method to the app delegate
- (void)applicationDidEnterBackground:(UIApplication *)application
and do something in the method like exit(0)
精彩评论