Quit app instead of entering background when receiving applicationDidEnterBackground

不羁的心 提交于 2019-12-12 10:59:54

问题


I wonder if it's possible to quit my program entirely after the user presses the Home button, rather than going into background run mode. Thanks.


回答1:


In your application's Info.plist, add a boolean key UIApplicationExitsOnSuspend with the value YES. See the Information Property List Key Reference for more information.




回答2:


Yup!! Although Apple will warn you that they don't want you to do this, it is possible, and I will trust that whatever reasons you have are legitimate. They will not exclude your app from the App Store just because it does not have backgrounding enabled.

In Xcode, find your <-yourappname->-Info.plist file. In Xcode 4, it is located in the "Supporting Files" group. In Xcode 3, it is located in the "Resources" group. Select the last entry and click the "+" icon to add another entry. Type "Application does not run in background" for the key (it will automatically fill this in), and then change the value to "YES".

Good luck with the app!!




回答3:


Refer to this question and its top voted answer for more information on the matter.


Using an Info.plist property UIApplicationExitsOnSuspend you can prevent your app from entering background and terminating as was the norm prior to iOS 4. You can read more about Info.plist keys to learn about additional options.

If you do not want your application to remain in the background when it is quit, you can explicitly opt out of the background execution model by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES



来源:https://stackoverflow.com/questions/5999638/quit-app-instead-of-entering-background-when-receiving-applicationdidenterbackgr

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