Xcode Error: displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract

I am working a lot with SwiftUI recently and encountered a problem when controlling NavigationLinks from outside the NavigationView with a @State.

Error Message: [Assert] displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract

What Do I do? I am using a Button outside a NavigationView to control a hierarchy of NavigationLinks inside the NavigationView via @State Properties which the Button is manipulating.

Code Block swift
struct OnboardingRoot: View {
@State var didCompletFirstView: Bool = false
@State var didCompleteSecondView: Bool = false
@State var didCompleteThirdView: Bool = false
var body: some View {
ZStack {
NavigationView {
Text("View 1")
.background(
NavigationLink(destination: Text("View 2"), isActive: $didCompleteFirstView) { EmptyView() }
)
/* This Hierarchy contains a Total of 4 Screens !!! */
}
VStack {
Spacer()
Button(action: { print("Calls a Function that updates the States accordingly.") }) { CustomButton(text: "Start") }
}
}
}
}


The Problem: As soon as I move to the Third Screen, I get the Error Message above. And also when moving between the Third and Fourth Screen, thee behavior is changing more or less to Random. *For example when finishing Screen 3, it comes again instead of Screen 4 and more.*

My Solution for this Problem: I was browsing for possible Solutions and found one Solution that seems to does the Job

Code Block swift
.navigationViewStyle(StackNavigationViewStyle())


My Question: Although this Line of Code does the Job, removes the Error Messages and prevents this Random Behavior, I could't find an Explanation of what causes the Error and why this is able to solve it. So if you have an Idea, please share it with me.

Thanks for your Help.

Replies

I am facing the very same problem that you have. Bumping this for attention.
I have exactly the same problem. But your line of code does not seem to do the trick for me... where exactly did you put
Code Block .navigationViewStyle(StackNavigationViewStyle())
?

Add a Comment
I am having the same issue, I get the same error. I have a list and when this loads, it flashes for a second, then my view get's blank.
On iPad it does show up correctly. It's really anoying.

I have the same problem. Xcode version: 12.5.1, Big Sur: 11.5.2.

Have the same issue, but it only shows on: iPhone X, iPhone XR, iPhone SE 2

other devices, it works like a champ :(