0

I am handling Touches delegates and UITapGestureRecognizer for single tap. Following are the methods. When I single tap on my View, I get three events in order of TouchesBegan, SingleTap, and TouchesEnded. Is there anyway to stop TouchesEnded event when I have SingleTap detected? Basicaaly I don't want to perform tasks in TouchesEnded if TouchesMoved didn't happen. I have done this using failTouchEnded BOOL variable in SingleTap and checking it in TouchesEnded but not sure if it is a good idea!

   - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    }

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
          failTouchEnded = NO;
    }

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
          if(failTouchEnded) return;

    }

    - (void)GestureView:(GestureView*)view handleSignleTap:(UITapGestureRecognizer*)recognizer {
          failTouchEnded = YES;
    }
Paresh Masani
  • 7,474
  • 12
  • 73
  • 139

1 Answers1

0

gestureRecognizer has a property cancelsTouchesInView. if it is YES (which is default) cancels the touches if the gesture recognizer recognizes the gesture. So you will get a touches canceled instead of touches ended. You should set delaysTouchesEnded to YES too if it is not YES

Siby
  • 318
  • 1
  • 10