用户按下主页按钮时中断方法?
当用户按下 iOS 设备上的主页按钮并且应用程序当前正在运行一个方法时会发生什么:该方法会完成运行还是会在中间中断?
What happens when a user pushes the home button on the iOS device and the app is currently running a method: Will the method finish running or will the method be interrupted in the middle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Maudicus 所写,在应用程序委托上调用
applicationWillResignActive:
以及applicationDidEnterBackground:
。您应该假设当前正在运行的任何方法都将被中断。如果您想确保执行特定操作,则应将其放入上述方法之一。Like Maudicus wrote,
applicationWillResignActive:
is called on the application delegate, as well asapplicationDidEnterBackground:
. You should assume that any method that is currently running will be interrupted. If you want to ensure that a particular operation is performed, you should put it in one of the aforementioned methods.