检测舞台管理器在SwiftUI中是否可用

jk9hmnmh  于 11个月前  发布在  Swift
关注(0)|答案(1)|浏览(58)

是否有任何方法可以从swiftUI应用程序检测舞台管理器在iPad上是否可用。谢了,谢了

kiayqfof

kiayqfof1#

从一些旧的建议中,我提出了以下解决方案:

var isStageManager: Bool {
    guard UIDevice.current.userInterfaceIdiom == .pad,
          let sceneDelegate = UIApplication.shared.connectedScenes.first as? UIWindowScene,
          let screenHeight = sceneDelegate.windows.last?.screen.bounds.height,
          let windowHeight = sceneDelegate.windows.last?.bounds.height else {
        return false
    }
    return screenHeight > windowHeight
}

字符串
似乎很有效。任何意见将不胜感激。

相关问题