gpt4 book ai didi

ios - 当 iOS 应用程序从应用程序切换器中滑动时调用哪个事件?

转载 作者:行者123 更新时间:2023-11-28 21:44:10 25 4
gpt4 key购买 nike

我想知道当我从应用程序切换器中滑出正在运行的应用程序时,我的 AppDelegate 中的哪个事件被调用了?我的目标 iOS 是 >= 7.0(即支持多任务)。

也许我只是不了解多任务处理范例本身...当我从应用程序切换器中滑出我的应用程序时,应用程序将被终止,对吧?还是继续在后台运行?

EDIT-1: 为什么我要问:在应用程序启动期间,我通过普通套接字连接到我的 Linux 游戏服务器。我想在应用程序终止时断开套接字。

EDIT-2:我不确定我是否在使用后台执行。我在运行循环对象中注册我的网络套接字,以异步接收来自服务器套接字的输入。此外,我安装了一种网络服务,可以定期测试网络连接。此服务使用 SCNetworkReachabilityScheduleWithRunLoop。

最佳答案

有些情况下 applicationWillTerminate: 会被调用,有时不会。

可以从 Apple documentation here 中阅读更多内容

摘录:

For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.

值得注意的是

After calling this method, the app also posts a UIApplicationWillTerminateNotification notification to give interested objects a chance to respond to the transition.

关于ios - 当 iOS 应用程序从应用程序切换器中滑动时调用哪个事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30936365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com