iphone - double tap fail safe way

后端 未结 3 1057
后悔当初
后悔当初 2021-01-13 18:44

I am trying to detect double taps on a view, but when the double tap comes, the first tap triggers an action on TouchesBegan, so, before detecting a double tap a single tap

3条回答
  •  佛祖请我去吃肉
    2021-01-13 18:44

    Are you looking at the tapCount? For example:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
             UITouch *touch = [[event allTouches] anyObject];
             if (touch.tapCount == 2) {
                      //double-tap action here
             }
    }
    

提交回复
热议问题