Swift 自从iOS 13 Beta 3以来,我的应用程序只显示一个黑色窗口

Swift 自从iOS 13 Beta 3以来,我的应用程序只显示一个黑色窗口,swift,ios13,Swift,Ios13,以下是我的场景代理方法的代码: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene

以下是我的场景代理方法的代码:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

    // Use a UIHostingController as window root view controller
    if let windowScene = scene as? UIWindowScene {
        let window = UIWindow(windowScene: windowScene)

    // Override point for customization after application launch.
    let context = AppDelegate.shared.persistentContainer.viewContext
    context.automaticallyMergesChangesFromParent = true

    window.rootViewController = UIHostingController(rootView: ContentView())
    self.window = window
    window.makeKeyAndVisible()
}

这是最初的默认设置。自beta 3以来,windows需要进行如下初始化:

    if let windowScene = scene as? UIWindowScene {
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = UIHostingController(rootView: ContentView(coordinator:coord, model:store))
        self.window = window
        window.makeKeyAndVisible()
    }

这是最初的默认设置。自beta 3以来,windows需要进行如下初始化:

    if let windowScene = scene as? UIWindowScene {
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = UIHostingController(rootView: ContentView(coordinator:coord, model:store))
        self.window = window
        window.makeKeyAndVisible()
    }

如果我没有swiftUI怎么办?@Fabiosoft那么显然你应该将视图控制器设置为rootViewController如果我没有swiftUI怎么办?@Fabiosoft那么显然你应该将视图控制器设置为rootViewController