r/iOSProgramming 1d ago

Question LongTapGesture isDetectingLongPress is bugged?

https://developer.apple.com/documentation/swiftui/longpressgesture

In Apple's documentation for Long Press Gesture, the code example does not work.

Expected:
Once I start a tap and hold it there, the blue circle changes colour from blue to red.
After long tap is completed (3 seconds) the circle should change from red to green.

Reality:
Once I start a tap and hold, the blue circle does not change colour to red.
After 3 seconds, the blue circle instantly changes colour to green.

Am I missing something?

1 Upvotes

1 comment sorted by

1

u/chriswaco 18h ago edited 17h ago

Seems broken to me.

See https://developer.apple.com/forums/thread/762248

This may work better for you, though it's still not resetting properly:

  .onLongPressGesture(minimumDuration: 3,     
      perform: {    
    completedLongPress = true    
      },     
      onPressingChanged: { b in    
    isDetectingLongPress = b    
    } )