Update: This is possible by using UIKit
in the .onAppear{}
modifier:
var body: some Scene {
WindowGroup {
NavigationView {
List(0..<10, rowContent: { i in
Text(String(describing: i))
})
.navigationTitle("One")
ListTwo()
VStack {
Text("Panel Three")
}
.navigationTitle("Three")
}.onAppear {
let root = UIApplication.shared.windows.first { $0.isKeyWindow }!.rootViewController
guard let split = root?.children[0] as? UISplitViewController else {
return
}
split.preferredDisplayMode = .twoBesideSecondary
}
}
}
Using the below code it’s possible to create a basic three-column iPad layout:
@main
struct threepanelApp: App {
var body: some Scene {
WindowGroup {
NavigationView {
List(0..<10, rowContent: { i in
Text(String(describing: i))
})
.listStyle(SidebarListStyle())
.navigationTitle("One")
List(10..<20, rowContent: { i in
Text(String(describing: i))
})
.navigationTitle("Two")
VStack {
Text("Panel Three")
}
.navigationTitle("Three")
}
}
}
}
However, the problem I’m having is that I want the app to launch with columns one, two, and three visible, not just two and three (as above).
No matter which combination of view modifiers I apply, I’m not able to achieve the above layout at app launch. Is there any way to achieve this?