I'm trying to add a drag gesture over a vertically scrollable view like List (mainly to detect horizontal drag only). I want the drag gesture to work in higher priority than the scrollable view scrolling behavior. On iOS 17 or prior, the below code works, however on iOS 18 beta, I'm facing that the scrollable view becomes unscrollable.
I found a similar topic in the developer forum as well. https://forums.developer.apple.com/forums/thread/760551
This is the minimum reproducible example:
struct ContentView: View {
var body: some View {
List {
ForEach(0..<100) {
Text("\($0)")
}
}
.highPriorityGesture(
DragGesture()
.onChanged({ value in
print("onChanged \(value)")
})
.onEnded({ value in
print("onEnded \(value)")
})
)
}
}
Any workaround?
The issue looks solved if I set 15
to the minimumDistance
of the DragGesture
. (FYI: The default value is 10
. It doesn't work with 14
so 15
seems to be the threshold)
.highPriorityGesture(
DragGesture(minimumDistance: 15)
...
)
Note: I tried with iOS 18 beta 6
Update: I noticed the issue does not reproduce in a real iPhone device (iOS 18 beta) in the first place :(