Niharika
Niharika

Reputation: 1198

Dismiss Presented view without any click event

I am working with an app in SwiftUI.I have presented one view using

.sheet(isPresented: $doIWantThisViewToShowUser, content: {
                            DraggedUsersMenu()
                        })

DraggedUsersMenu()

is view I wanted to present. Here I have few stacks from which I need to navigate to another contentView. Now navigation Works perfectly My 2nd screen is there,but its behind this presented View. Is there a way to dismiss() this view automatically, once we navigate to another controller.?

Upvotes: 0

Views: 399

Answers (1)

RelativeJoe
RelativeJoe

Reputation: 5114

Add this: @Environment(\.presentationMode) var presentationMode.

And when you want to dismiss use: presentationMode.wrappedValue.dismiss()

Upvotes: 0

Related Questions