Post

Replies

Boosts

Views

Activity

LongPressGesture.updating(_:body:)
Hello, I'm using LongPressGesture to provide haptic & color change feedback on a long press action. This fails to call the .updating(_:body:) method on every iOS 18.0 beta. It works fine on iOS 17. The following code, taken directly from Apple's documentation illustrates the problem. The .updating() closure is never called, while the .onEnded() closure is called correctly. Instead of a gradual color transition the example code generates a delayed sharp switch from Red to Blue, preventing interactive user feedback. struct LongPressGestureView: View { @GestureState private var isDetectingLongPress = false @State private var completedLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 3) .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState transaction.animation = Animation.easeIn(duration: 2.0) } .onEnded { finished in self.completedLongPress = finished } } var body: some View { Circle() .fill(self.isDetectingLongPress ? Color.red : (self.completedLongPress ? Color.green : Color.blue)) .frame(width: 100, height: 100, alignment: .center) .gesture(longPress) } } Can anyone share tips on a workaround or potential fix application-side?
4
4
928
Aug ’24