Go to a new view using SwiftUI

前端 未结 12 1881
走了就别回头了
走了就别回头了 2020-12-08 19:28

I\'ve got a basic view with a button using SwiftUI and I\'m trying to present a new screen/view when the button is tapped. How do I do this? Am I suppose to create a delegat

12条回答
  •  猫巷女王i
    2020-12-08 20:02

    You can no longer use NavigationButton. Instead you should use NavigationLink.

    struct ContentView: View {
        var body: some View {
            NavigationView {
                NavigationLink(destination: DetailView()) {
                    Text("Push new screen")
                }
            }
        }
    }
    

提交回复
热议问题