The Navigation Bar title is missing when I put the view within a TabView. Anyone know what's the problem?
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
Text("Tab 1")
.tabItem {
Text("Tab 1")
}
.navigationBarTitle("Tab 1")
.navigationBarHidden(false)
Text("Tab 2")
.tabItem {
Text("Tab 2")
}
.navigationBarTitle("Tab 2")
.navigationBarHidden(false)
}
}
}
}
Update: Xcode 13.4 / iOS 15.5
A possible approach is to join navigation view title with tab view selection dynamically, like
Original
TabBar
is designed to be a root view, so to achieve your needs the following approach can be used instead