Search code examples
iosuilabeluigesturerecognizertouchesbegan

Detect number of touches


I have a problem, In my app I have a Label and when I touch on it a method is fired, I implemented with -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event, the problem is that when I touch, the method is fired (everything is working) but I want when I touch once again another method to fire. How to do that???


Solution

  • You're talking about changing state after a touch. Most people would use just a boolean, or an integer enum to keep track of what state they're in, and fork the code accordingly. However, if you need to discern between a tap, a double tap, a triple tap, a pan, or press and hold, then you should look at gesture recognizers, and in particular, watch the WWDC video where they were introduced (2011?).