【发布时间】:2021-01-24 07:34:40
【问题描述】:
我正在使用 Swift UI 2.0,目前的设置如下:
@main
struct MyApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
InitialView()
}
.onChange(of: scenePhase) { (newScenePhase) in
switch newScenePhase {
case .active:
print("scene is now active!")
case .inactive:
print("scene is now inactive!")
case .background:
print("scene is now in the background!")
@unknown default:
print("sus")
}
}
}
}
这很好,但这些都不能解释应用程序终止的情况(即用户双击主页按钮并在应用程序上向上滑动)。我该如何解释这种情况?
我尝试实现 applicationWillTerminate(_:) 失败,因此我们将不胜感激。
谢谢!
【问题讨论】:
-
当用户滑动应用时没有调用函数。
标签: ios swift swiftui appdelegate uiscenedelegate