UILongPressGestureRecognizer stop handle without stop touching

前端 未结 2 474
轻奢々
轻奢々 2021-01-05 11:28

I\'m using UILongPressGestureRecognizer class to handle if one item is being selected.

The logic is as follows: User press during 1 second an item (UIView subclass).

2条回答
  •  温柔的废话
    2021-01-05 11:55

    Does the custom UIView class have its own touch handling code? If not, a simple solution is to set the allowableMovement property of the UILongPressGestureRecognizer to CGFLOAT_MAX, or some big number, and use the gesture update callbacks to drag your custom view around. You can get the displacement using the - (CGPoint)locationInView:(UIView *)view method on the superview, and compare its position to when the recognizer began.

提交回复
热议问题