Can I cancel the method "applicationDidEnterBackground?

淺唱寂寞╮ 提交于 2019-12-13 12:32:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!