Search code examples
iphonetap

Double Tap for certain part of view


I am bit stacked with a functionality that should perform a certain task after double taping on a certain place on UIView. I know how to count number of taps, but do not know how to determinate which place has been tapped and I guess to compare with CGRect of view which was specified for doing this action.

thanx in advance


Solution

  • We can detect with touchesBegan

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
         NSUInteger numTaps = [[touches anyObject] tapCount];
    UITouch* t;
    
    if([[event allTouches] count]==2)//double tap
        {
         t=[[[event allTouches] allObjects] objectAtIndex:0];
     CGPoint p1=[t locationInView:self.view];
         }
    

    numTaps gives the nuber of taps .

    P1 has the point where it is tapped.

    All the best.