SwiftUI - Split View on iPad problem

Is there an simple way to use the UISplitViewController with SwiftUI?

Currently I use a NavigationView. The problem is, that the ListView on the left only shows in landscape mode and not in portrait mode.

This is the example of my code:
Code Block SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
ListView()
DetailView()
}.navigationViewStyle(DoubleColumnNavigationViewStyle())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct ListView: View {
var body: some View {
List(0 ..< 5) { item in
NavigationLink(destination: DetailView()) {
Text("List Item")
}
}
.navigationTitle("My List")
}
}
struct DetailView: View {
var body: some View {
Text("Hallo")
}
}

I tested it with a padding after navigationViewStyle but the List View only displays in landscape mode.

Replies

SwiftUI uses the default two column behaviour that does what you are experiencing. I had to use a UISplitView at the top level of my app to get around that.