SwiftUI Xcode Beta 5 NavigationView横向空白屏

时间:2019-08-12 08:27:31

标签: ios swiftui

我试图在NavigationView中创建一个视图,但是当我从纵向向上更改为横向模式时,它会出现空白屏幕。

  • 人物肖像

image potrait

  • 风景图片

image landscape

// ContentView.swift

struct ContentView: View {
    var body: some View {
        NavigationView {
            Text("Hello")
                .navigationBarTitle(Text("Hhh"))
        }
    }
}

#if DEBUG
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif




// SceneDelegate.swift

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

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

0 个答案:

没有答案