如何在 SwiftUI 中的视图上推送点击手势的视图?

Kou*_*udi 2 ios swift swiftui

我想在点击图像时推送视图。到目前为止我的代码:

struct Home: View {
    var body: some View {
        NavigationView {
            VStack {
                Image("image")
                    .onTapGesture {
                   //navigation code here
                }
                Text("Tap on image to find details")
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如何实现这样的导航呢?谢谢!

Asp*_*eri 5

为什么不能使用如下标准的 NavigationLink?

NavigationView {
    VStack {
        NavigationLink(destination: SomeDestinationViewHere()) {
            Image("image")
        }
        Text("Tap on image to find details")
    }
}
Run Code Online (Sandbox Code Playgroud)