Error message:
[Assert] displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract.
Reproduce code:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: DetailView()) {
Text("First View")
}
}
}
}
}
struct DetailView: View {
var body: some View {
List {
NavigationLink(destination: Text("Detail Title")) {
Text("New View")
}
}
.navigationBarItems(trailing:
Button(action: {
print("Clicked")
}) {
Image(systemName: "square.and.arrow.up")
})
}
}
Solution: attach .navigationViewStyle(StackNavigationViewStyle())
tot the NavigationView
.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: DetailView()) {
Text("First View")
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
struct DetailView: View {
var body: some View {
List {
NavigationLink(destination: Text("Detail Title")) {
Text("New View")
}
}
.navigationBarItems(trailing:
Button(action: {
print("Clicked")
}) {
Image(systemName: "square.and.arrow.up")
})
}
}
Bug: the list cell will become gray when navigating back.