Question

guys, I want to set actions to touches. If people make single touch - one action, else - different. I've written this code in my touchesBegan method:

        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");
        }

But it's detecting single touch, and after it double, but it's incorrect in my situation. Have you any ideas?

Was it helpful?

Solution

Check this link. Just Configure number of tap required by setting

[tapGestureRecognizer   setNumberOfTapsRequired:2];

and then handle this method

- (void)handleTap:(UITapGestureRecognizer *)sender {    
       if (sender.state == UIGestureRecognizerStateEnded)     {     
         // handling code     
       } 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top