-1

伙计们,我想为触摸设置动作。如果人们进行单触 - 一个动作,否则 - 不同。我在 touchesBegan 方法中编写了这段代码:

        UITouch *touch = [event.allTouches anyObject];
        BOOL tappedTwice = NO;
        if ([touch tapCount] == 2) {
            tappedTwice = YES;
            NSLog(@"double touch");
        }
        else if ([touch tapCount] == 1 && !tappedTwice) {
            NSLog(@"single touch");
        }

但它正在检测单次触摸,然后是双次触摸,但在我的情况下它是不正确的。你有什么想法吗?

4

1 回答 1

2

检查此链接。只需通过设置配置所需的点击次数

[tapGestureRecognizer   setNumberOfTapsRequired:2];

然后处理这个方法

- (void)handleTap:(UITapGestureRecognizer *)sender {    
       if (sender.state == UIGestureRecognizerStateEnded)     {     
         // handling code     
       } 
}
于 2012-01-31T05:16:30.680 回答