I want to perform a function when a certain NavigationLink is tapped / touched. I assume that .onTapGesture
or something like it would be useful, but when I add .onTapGesture
it never triggers upon touching my NavigationLink. Do I need to use a different event handler or is something else wrong?
Sample code:
struct ExampleView: View {
var body: some View {
NavigationView() {
NavigationLink(destination: Text("Destination")) {
Text("Navigate")
}
.onTapGesture {
print("Tapped")
}
}
}
}