When the user single taps my view, i need one specific method to run. When the user double taps, i need another method do take place.
The problem is that the double tap triggers the single tap, and it introduce bugs in my logic. I can't use UIGestureRecognizer because i need to keep track of the points.
I try some booleans, but no chance. I also tried the cancel/perfomSelector-delay technique, but it does not work (that's strange because other folks on other forums said it works, maybe the simulator touch detection is different ?)
I'm trying to let the user set the position (drag, rotate) of a board piece, but i need to be aware of piece intersections, clip to the board area, etc, that's why a simple boolean will not solve the problem.
Thanks in advance!
Check this, seems right what you are looking for:
Possibly I don't understand exactly what you mean by "i need to keep track of the points", but I don't see any problems with doing this with a gesture recognizer.
Just implement the UIGestureRecognizer delegate methods by setting the delegate properly.
Also add this line of code
Swift Solution :
Swift 3 Solution:
In the code line singleTap.require(toFail: doubleTap) we are forcing the single tap to wait and ensure that the tap even is not a double tap. Which means we are asking to ensure the double tap event has failed hence it is concluded as a single tap.