我试图在NavigationView中创建一个视图,但是当我从纵向向上更改为横向模式时,它会出现空白屏幕。
// 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()
}
}