You need to subclass it to use touchesBegan
and touchesMoved
anyway. I'd do UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionLeft
like you said, then set up two CGRect
s, one for acceptable starting points, one for acceptable end points. Then use the UIGestureRecognizerDelegate
method gestureRecognizer:shouldReceiveTouch:
, and check if the touch point is in the acceptable start rect by using CGRectContainsPoint()
. Then (I think) in your UISwipeGestureRecognizer
subclass, override touchesEnded:withEvent:
, and check if the end touch is in the acceptable rect. If it's not, set the state to UIGestureRecognizerStateCancelled
(or however you're supposed to cancel a gesture). Also make sure the view it's attached to has its multipleTouchEnabled
property set. I haven't actually tried this, but something of the sort should do it. Good luck!
EDIT
Actually, if you didn't want to have to worry about specific rect values for the acceptable start/end points, and make it device independent, you could do this:
//swap in whatever percentage of the screen's width/height you want in place of ".75f"
//set the origin for acceptable start points
CGFloat startRect_x = self.view.frame.size.width * .75f;
CGFloat startRect_y = self.view.frame.size.height * .75f;
//set the size
CGFloat rectWidth = self.view.frame.size.width - startRect_x;
CGFloat rectHeight = self.view.frame.size.height - startRect_y;
//make the acceptable start point rect
CGRect startRect = CGRectMake(startRect_x, startRect_y, rectWidth, rectHeight);
//set the origin for the accepable end points
CGFloat endRect_x = self.view.center.x - rectWidth/2;
CGFloat endRect_y = self.view.center.y - rectHeight/2;
//make the acceptable end point rect
CGRect endRect = CGRectMake(endRect_x, endRect_y, rectWidth, rectHeight);