Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Navigation Stack pops back on ObservableObject update
I fixed the issue by using a button with a navigation link instead of just NavigationLink and now it doesn't pop to the root view when the parent's state changes. Here is the code: struct CustomNavigationLink<Content, Destination>: View where Destination: View, Content: View {   let destination: Destination?   let content: () -> Content   @State private var isActive = false   init(destination: Destination, @ViewBuilder content: @escaping () -> Content) {     self.content = content     self.destination = destination   }   var body: some View {     ZStack {       NavigationLink(destination: destination, isActive: $isActive) {}       Button(action: {         self.isActive = true       }) {         content()       }     }   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to SwiftUI Navigation Stack pops back on ObservableObject update
I fixed the issue by using a button with a navigation link instead of just NavigationLink and now it doesn't pop to the root view when the parent's state changes. Here is the code: struct CustomNavigationLink<Content, Destination>: View where Destination: View, Content: View {   let destination: Destination?   let content: () -> Content   @State private var isActive = false   init(destination: Destination, @ViewBuilder content: @escaping () -> Content) {     self.content = content     self.destination = destination   }   var body: some View {     ZStack {       NavigationLink(destination: destination, isActive: $isActive) {}       Button(action: {         self.isActive = true       }) {         content()       }     }   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to SwiftUI Navigation Stack pops back on ObservableObject update
Having the same issue on iOS 15, before updating it was working fine (on iOS 14.5), no popping back to the parent view
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21