Reputation: 436
I've been learning SwiftUI for a while, and it's really great. I run into a layout problem when I tried to add a TabView
in sidebar view of NavigationSplitView
. It's running as expected on iPhone simulator and Mac, but the width of TabView
is wrong when running on iPad. It's wider than the sidebar that containing it.
Am I doing something wrong? Please help. Thanks.
struct TestView: View {
var body: some View {
NavigationSplitView {
TabView {
Text("This is sidebar 1")
.tabItem {
VStack {
Image(systemName: "gear")
Text("Sidebar 1")
}
}
.tag(0)
Text("This is sidebar 2")
.tabItem {
VStack {
Image(systemName: "gear")
Text("Sidebar 2")
}
}
.tag(1)
}
} detail: {
Text("This is detail")
}
}
}
Used a custom view with same result.
Upvotes: 0
Views: 200