gpt4 book ai didi

ios - 如何在 Swift5 中关闭应用程序时更改应用程序状态?

转载 作者:行者123 更新时间:2023-12-01 16:21:25 24 4
gpt4 key购买 nike

我的应用运行没有问题。

但是,如果您在我的应用程序上点击分享按钮并完成分享,关闭我的应用程序并在另一个应用程序上点击分享的图片,它不会进入登录屏幕。为什么不识别后台状态?

switch UIApplication.shared.applicationState {
case .background:
LoginScreen()
break
case .inactive:
WebViewScreen()
break
case .active:
WebViewScreen()
break
default:
break
}
return true

因此,如果我按下“共享”按钮并转到我的应用程序,我可以准确无误地转到 webview 屏幕。但我不想在应用程序关闭时转到 webview 屏幕。

编辑:2016年文件

Table 2-3 App states State

Description

Not running

The app has not been launched or was running but was terminated by the system.

Inactive

The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.

Active

The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background

The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see Background Execution.

Suspended

The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code.

When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

2016 Apple 文档的状态值为“Notruning”。现在没了?是否有替代状态​​值?

最佳答案

当应用程序覆盖另一个应用程序时,例如来电或通过共享按钮。您的应用程序将进入非事件状态,而不是在后台。请打印语句并尝试找出您的应用程序处于哪种状态,我怀疑它不是处于后台状态。

关于ios - 如何在 Swift5 中关闭应用程序时更改应用程序状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58759315/

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