'SwiftUI .onTapGesture always higher priority than .swipeActions
How do I make my the code in .swipeActions be called instead of the one in .onTapGesture?
I have a SwiftUI view like follows:
struct ContentView: View {
var body: some View {
VStack {
List {
Text("Hello, World!")
.swipeActions {
Button(role: .destructive) {
print("Tapped Delete button")
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
.padding()
.onTapGesture {
print("Tapped VStack")
}
}
}
This produces an output like this:
You can see, that only the code inside of .onTapGesture is called. The code inside of .swipeActions is never called. How can I change the priority, so that the code inside of .swipeActions functions correctly?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

