iOS Tap gesture state begin doesn't hit

前端 未结 5 1102
半阙折子戏
半阙折子戏 2021-01-12 13:56

I have made a view clickable with a tap gesture recognizer, which is working just fine. But I want to highlight the view when the touch happens en remove it when the touch e

5条回答
  •  [愿得一人]
    2021-01-12 14:24

    UITapGestureRecognizer will never go in the UIGestureRecognizerStateBegan state. Only continuous gestures (such as a swipe or a pinch) will result for their recognizers going from UIGestureRecognizerStatePossible to UIGestureRecognizerStateBegan. Discrete gestures, such as a tap, put their recognizers directly into UIGestureRecognizerStateRecognized, i.e. for a single tap, right into UIGestureRecognizerStateEnded.

    That said, maybe you're looking for a UILongPressGestureRecognizer, which is a continuous recognizer that will enter UIGestureRecognizerStateBegan, allowing you to discern beginning and end of touch?

提交回复
热议问题