I have an iPad app I am writing with SwiftUI. I would like to have a split NavigationView with the left-hand (navigation) side displaying a TabView and the right-hand (content) side displaying other various views. I am seeing some strange behavior, however. If I have, say, 4 tabs I only see tabs 2-4 displayed. Tab 1 does not appear. If I only have 2 tabs, though, I see that Tab 1 is displayed FAR to the left to the point it is partially cut off.
I setup my NavigationView like this:
struct SidebarContentView: View {
var body: some View {
NavigationView {
TabbedNavigationView()
Text("DETAIL")
}
}
}
My TabView is then setup like this:
struct TabbedNavigationView: View {
var body: some View {
TabView {
EmptyView()
Text("TAB 1")
.tabItem {
Text("Tab 1")
}
Text("TAB 2")
.tabItem {
Text("Tab 2")
}
Text("TAB 3")
.tabItem {
Text("Tab 3")
}
Text("TAB 4")
.tabItem {
Text("Tab 4")
}
}
}
}
I would expect all tabs to be visible on the left. Instead, when the view renders it looks like this.
You see that "Tab 1" isn't displayed at all, even though it's obvious that "Tab 1" is the default selected tab (as evidenced by "TAB 1" being displayed on the navigation side). Any idea why I can't get the TabBar inside my NavigationView to play nicely? Is there something more I need to do here?