Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Navigation link issue
I can see why you have that problem. SwiftUI NavigationLink(destination: ExampleView(), isActive: self.$isActive) {} When you create a NavigationLink with the parameter isActive, you link that instance of NavigationLink to the state variable. When the value of the variables changes, all correlating views are updated, including NavigationLink. Basically, pressing on the NavigationLink changes the value of isActive to true, and so every other NavigationLink, which is connected to the variable, also gets the information, that it should push a new view. The answer would be to remove that entire state variable and add this variable in the destination view: SwiftUI @Environment(\.presentationMode) var presentationMode: BindingPresentationMode And then use that method to dismiss current view: SwiftUI presentationMode.wrappedValue.dismiss()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21