0

How can i navigate from view to another using a button instead of using NavigationView or a sheet.

kind regards

TheWhiteSword
  • 115
  • 1
  • 10
  • What do you mean by "navigate" then? – Asperi Apr 12 '20 at 16:02
  • i would have a button that takes me to another whole view instead of using NavigationView. i tried NavigationButton but it got deprecated and don't want to display the view in a sheet. thanks for asking – TheWhiteSword Apr 12 '20 at 19:02

1 Answers1

0

try this:

you cannot navigate without navigationview, but you can hide navigationbar if you want to.

struct ContentView: View {

    @State var navigate = false

    var body: some View {
        NavigationView {
            VStack {
                NavigationLink(destination: Text("aha"), isActive: self.$navigate) {
                    EmptyView().hidden()
                }.frame(height:0)
                Button(action: {
                    self.navigate = true
                }) {
                    Text("go")
                }
            }
        }
    }
}
Chris
  • 7,579
  • 3
  • 18
  • 38
  • Really there is no other way to implement the same thing in a button ? Please i need more details about the SceneDelegate, i think the whole app is just a single scene to display views in a structured way (NavigationView) thanks for your reply – TheWhiteSword Apr 12 '20 at 19:06