2

I need to pop to the root view from a deep detail view. Found this solution on StackOverflow SwiftUI: How to pop to root view for WatchOS?. The following solution using isDetailList and isActive works quite well for iOS, it does not work for watchOS. The isDetailList command is unavailable in watchOS.

Below is the code that is I am using to push a view to navigation which is bounded by a condition using the tag. So we can't use both tag and isActive parameter into NavigationLink simultaneously. So looking for a solution that popup the root viewController.

Button(action: {
        nextBtnPressed()
        
    }, label: {
        Text("Next")
            .font(.system(size: 14, weight: .semibold))
    })
    .frame(height: 35, alignment: .center)
    .background(Color.init(hex: "0A2248"))
    .cornerRadius(15)
    .disabled(false)
    .background(
        
        
        NavigationLink(
            destination: SetTimerView(shouldPopToRootView: self.$shouldPopToRootView, shower_type: self.showerType),
            tag: "true",
            selection: $movetoNextScreen,
            label: { EmptyView() }
        )
        .opacity(0)
    )
}
2
  • When using tag instead of isActive, the selection is the bound value you use to programmatically navigate. That is, set movetoNextScreen to nil.
    – Adam
    Commented Apr 29, 2021 at 17:09
  • you mean to say that, setting movetoNextScreen nil will pop all the views upto root view controller Commented Apr 30, 2021 at 8:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.