700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > iOS 4中禁止程序退出后保留在后台的方法

iOS 4中禁止程序退出后保留在后台的方法

时间:2019-11-20 02:03:34

相关推荐

iOS 4中禁止程序退出后保留在后台的方法

只需要在plist中加入UIApplicationExitsOnSuspend。

Opting Out of Background Execution

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. When an application opts out, it cycles between the not running, inactive, and active states and never enters the background or suspended states. When the user taps the Home button to quit the application, the applicationWillTerminate: method of the application delegate is called and the application has approximately five seconds to clean up and exit before it is terminated and moved back to the not running state.

Opting out of background execution may be preferable for certain types of applications. Specifically, if coding for the background may require adding significant complexity to your application, terminating the application may be a simpler solution. Also, if your application consumes a large amount of memory, the system might need to terminate your application quickly anyway to make room for other applications. Thus, opting to terminate, instead of switch to the background, might yield the same results and save you development time and effort.

Note: Explicitly opting out of background execution is necessary only if your application is linked against iPhone SDK 4 and later. Applications linked against earlier versions of the SDK do not support background execution as a rule and therefore do not need to opt out explicitly.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。