【发布时间】:2020-07-27 12:45:46
【问题描述】:
由于应用程序特定的原因,我必须在 NavigationView 中嵌套 TabView。但是标签项的导航栏标题没有显示,只是一个空的导航栏。
有什么解决办法吗?
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
Text("Tab 1")
.navigationBarTitle("Tab 1") // is ignored, only an empty string is displayed
.tabItem {
Text("Tab 1")
}
Text("Tab 2")
.navigationBarTitle("Tab 2") // is ignored, only an empty string is displayed
.tabItem {
Text("Tab 2")
}
}
// this would display a navigation bar title, but then the title is the same for all tab items
//.navigationBarTitle("TabView title")
}
}
}
【问题讨论】:
标签: swiftui