filtering single and double taps

前端 未结 4 1614
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 03:59

When the user single taps my view, i need one specific method to run. When the user double taps, i need another method do take place.

The problem is that the double

4条回答
  •  攒了一身酷
    2020-12-09 05:00

    Just implement the UIGestureRecognizer delegate methods by setting the delegate properly.

     - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
                return  YES;
            }
    
        - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
            return YES;
        }
    

    Also add this line of code

    [singleTap requireGestureRecognizerToFail:doubleTap];
    

提交回复
热议问题