How to manually go back to folders View on document-based SwiftUI iOS apps

I have the simplest document-based SwiftUI iOS app, directly from the xcode template. When the app is open, it shows by default the folders view with the ability to either open a file or create a new one. When you open/create a file, it opens a new View with a navigation bar that enables to close the current file and go back to the folders view.

I hid the navigation bar with a .navigationBarHidden(true) and I want to add a custom button to be able to go back to the folders view.

I tried the usual:

@Environment(\.presentationMode) var mode: Binding<PresentationMode> Button(action: {   self.mode.wrappedValue.dismiss() }, label: {   Text("Back") }) 

But it does nothing. How can I manually go back to the folder view?

Asked on August 31, 2020 in iOS,   Swift.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.