SwiftUI gestures like long press and drag conflict with ScrollView scrolling. The post explores why this happens and proposes a workaround using ButtonStyle, which can detect press/release states without blocking scroll gestures. A custom ScrollViewGestureButton is built step-by-step, supporting press, release, double tap, long press, and drag gestures. An update notes that iOS 18 simplifies this by allowing simultaneous gestures natively, and an open-source GestureButton library is available with the updated approach.

12m read timeFrom danielsaidi.com
Post cover image
Table of contents
Update 2024-09-02The problemWhy does this happen?Some non-working solutionsFinding a workaroundBuilding a scroll view gesture buttonGoing furtherConclusion