简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM