问题
I wanted to cancel the method, to request a confirmation from the user when he presses the button "HOME" where on iPhone would go into the execution in background.
If the user accepts, enters into the execution in background, if not accept, I do not do anything.
I looked in the FORUM, in the documentation from Apple and I found nothing.
Could anyone help me?
Thanks in advance!
回答1:
No you can't override this. The event will always fire but it does give you time to clean up before you move to the background.
Your delegate’s applicationDidEnterBackground: method has approximately five seconds to finish any tasks and return. In practice, this method should return as quickly as possible. If the method does not return before time runs out, your application is terminated and purged from memory. If you still need more time to perform tasks, call the beginBackgroundTaskWithExpirationHandler: method to request background execution time and then start any long-running tasks in a secondary thread. Regardless of whether you start any background tasks, the applicationDidEnterBackground: method must still exit within five seconds
iOS Application Programming Guide
回答2:
No, you can't override the operating system or the user's button press.
If the user presses the button to send the app into the background, the app goes into the background.
来源:https://stackoverflow.com/questions/4489890/can-i-cancel-the-method-applicationdidenterbackground