I would like to add special gestures to my application.
For example, if the user will swipe an X on the screen, I want to treat it as delete, or if the user will swipe a V – I want to treat it as confirm.
I was thinking of subsclassing one of the UIGesture classes, but not sure how to detect what I need.
UPDATE: I found an example for the checkmark gesture (http://conceitedcode.com/2010/09/custom-gesture-recognizers/), but no clue how to implement the X one.
You cant really recognize an “X”, that would be 2 gestures. You would have to do some kind of gesture saver to see if the previous one was a diagonal stroke, and if this one is one… and all kinds of madness. You could do something like diagonally down, straight up, and then diagonally down the other direction. Ill leave that code to you 😛
But, what you want to do is subclass UIGestureRecognizer. Here is some documentation on it. You need to implement the following methods:
This is the code used to recognize a “V” gesture.
That should get you pointed in the right direction, good luck.