当我打开我的应用并做一些事情时(比如导航到某个
ViewController
),然后我有几分钟不触摸应用 iPhone 被锁定(应用进入 BackGround State)
。
现在
分钟(大约 5 分钟)当我解锁 iPhone 我的应用程序被杀死了。
不在打开状态(事件状态
)。我需要通过单击应用程序图标来明确打开它。
BackGround State
如果您正确检查了您的应用程序没有崩溃,它会显示在多任务 UI 中,而您不是 executing code in the background ,那么我会说您的应用程序正在被系统终止(由于内存压力或其他原因)。
Apps must be prepared for termination to happen at any time and should not wait to save user data or perform other critical tasks. System-initiated termination is a normal part of an app’s life cycle. The system usually terminates apps so that it can reclaim memory and make room for other apps being launched by the user, but the system may also terminate apps that are misbehaving or not responding to events in a timely manner.
Suspended apps receive no notification when they are terminated; the system kills the process and reclaims the corresponding memory. If an app is currently running in the background and not suspended, the system calls the
applicationWillTerminate:
of its app delegate prior to termination.
所以在您的场景中发生的情况是应用程序进入了暂停状态,并且在一段时间后(您提到的那 5 分钟)应用程序被系统终止了。
看看Background Transition Cycle .
如果您想减少应用程序因内存压力而终止的可能性,请查看 What to Do When Your App Enters the Background ,具体来说:
Free up memory as needed. Release any cached data that you do not need and do any simple cleanup that might reduce your app’s memory footprint. Apps with large memory footprints are the first to be terminated by the system, so release image resources, data caches, and any other objects that you no longer need. For more information, see Reduce Your Memory Footprint.
关于ios - 应用程序在后台保持几分钟后被杀死,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35551294/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |