SwiftUI iPad应用程序在启用多个窗口支持时显示黑屏 [英] SwiftUI iPad app shows black screen on enabling multiple window support
本文介绍了SwiftUI iPad应用程序在启用多个窗口支持时显示黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在macOS Catalina上使用SwiftUI,当启用支持多个窗口"时,我的iPad应用在模拟器中启动时显示黑屏
Using SwiftUI on macOS Catalina, when enabling "Support multiple windows", my iPad app shows a black screen on launch in the simulator
我正在使用现有的SwiftUI项目,唯一的变化是单击支持多个窗口"复选框
I'm using the stock SwiftUI project, with the only change being clicking the "Support multiple windows" checkbox
这来自我的SceneDelegate,我认为这是在SwiftUI中设置窗口的正确方法
This is from my SceneDelegate, which I believe is the proper way to set up a window in SwiftUI
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
在我的Info.plist中,我相信我已经拥有了所有需要的东西
In my Info.plist I believe I have everything I need
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
推荐答案
窗口必须初始化为
let window = UIWindow(windowScene: scene as! UIWindowScene)
这篇关于SwiftUI iPad应用程序在启用多个窗口支持时显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文