I need to catch two different swipping gestures using UISwipeGestureRecognizer(for example, UISwipeGestureRecognizerDirectionRight and UISwip
The answer: "Um, a quick look at the documentation..." from Phoenix absolutely will not work!
He is setting a mask, then using the same variable to test as if the recognizer cleared it and set a single bit. It stores, as he correctly quoted from the documentation:
The permitted directions of the swipe
sender.direction
will simply return the mask you set initially and in his example, will never resolve to a single direction!
UISwipeGestureRecognizerDirectionRight == 1
UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft == 3
Additionaly, for most cases you don't need to:
The following works for me:
UISwipeGestureRecognizer* swipe;
swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeL)] autorelease];
swipe.direction = UISwipeGestureRecognizerDirectionLeft;
[view addGestureRecognizer:swipe];
swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeR)] autorelease];
swipe.direction = UISwipeGestureRecognizerDirectionRight; // default
[view addGestureRecognizer:swipe];