Dismiss Presented view without any click event

286 views Asked by At

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.?

1

There are 1 answers

0
Timmy On

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

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