Saturday, June 13, 2026
HomeiOS Developmentios - Tips on how to dismiss a SwiftUI NavigationView from a...

ios – Tips on how to dismiss a SwiftUI NavigationView from a father or mother view

[ad_1]

Often, to implement a “customized dismiss button” inside a SwiftUI NavigationView, I might use @Setting(.dismiss) personal var dismiss, after which name dismiss() to dismiss the view.

Nevertheless, suppose I wish to dismiss a NavigationLink from a father or mother of the NavigationView?

struct SwiftUIView: View {
    var physique: some View {
        HStack {
            Button(motion: {
                // dismiss view
            }) {
                Textual content("Dismiss View")
            } // assume this button is at all times seen
            NavigationView {
                Textual content("That is the NavigationView")
                NavigationLink {
                    Textual content("That is the view I wish to exit")
                } label: {
                    Textual content("Go to view I wish to exit")
                }
            }
        }
    }
}

How would I’m going about dismissing the view displaying That is the view I wish to exit, by clicking the Dismiss View button within the father or mother view?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments