I have very simple code, like so:
struct ContentView: View {
var body: some View {
TabView {
FirstView()
}
.tabViewStyle(.page)
}
}
struct FirstView: View {
var body: some View {
NavigationView {
Text("Content")
.navigationTitle("Title")
}
}
}
When using NavigationView
in a TabView
, strange behaviour occurs. In iOS 15, I get errors such as:
... [LayoutConstraints] Unable to simultaneously satisfy constraints.
...
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000010e5ae0 'BIB_Leading_Leading' H:|-(0)-[_UIModernBarButton:0x7fbd1d618dc0] (active, names: '|':_UIButtonBarButton:0x7fbd1d506d80 )>
In iOS 14, I get the same logs but also the view looks wrong:
And upon clicking on the back button 'Title', I get the log:
... [Assert] unknown display mode: Automatic
When adding .navigationViewStyle(.stack)
, the title has no space on the leading side like it would by default:
And when using this style with more complex content such as below, the views go behind the navigation title and just ignore it:
NavigationView {
VStack {
Text("Top")
Spacer()
Text("Bottom")
}
.navigationTitle("Title")
}
.navigationViewStyle(.stack)
How can I fix this for iOS 14? I can accept the logs for both, but what workaround (or real solution if possible) is there to fix this?