Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

straber

macrumors member
Original poster
Jul 3, 2012
60
0
I have a subclass of UITableView which I want to perform a different action depending on whether the user single taps a cell or double taps. The problem is that the double tap causes both events to fire.

I'm handling it like this:

Code:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if(((UITouch *)[touches anyObject]).tapCount == 2) {
        wasDoubleTap = YES;
        NSLog(@"double tap");
    }
    else {
        wasDoubleTap = NO;
        NSLog(@"single tap");
    }
    [super touchesEnded:touches withEvent:event];
}

and double tapping causes "single tap" and then "double tap" to print out.

Does anyone know of any way I can suppress the single tap to see if it's actually a double tap?

Thanks.
 
These days one does this by using gesture recognizers. You create a single tab and a double tap gesture recognizer. If are only interested in the double tap you make the single tap recognizer fail if the double tap recognizer succeeds.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.