how detect swipe gesture direction?

Here is an example from one of my projects: // … UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; swipeRight.direction = UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:swipeRight]; UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; swipeUp.direction = UISwipeGestureRecognizerDirectionUp; [self.view addGestureRecognizer:swipeUp]; UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; swipeDown.direction … Read more

How to recognize swipe in all 4 directions?

You set the direction like this UISwipeGestureRecognizer *Swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)]; Swipe.direction = (UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionUp); That’s what the direction will be when you get the callback, so it is normal that all your tests fails. If you had – (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender { if ( sender.direction | UISwipeGestureRecognizerDirectionLeft … Read more

How to recognize swipe in all 4 directions

You need to have one UISwipeGestureRecognizer for each direction. It’s a little weird because the UISwipeGestureRecognizer.direction property is an options-style bit mask, but each recognizer can only handle one direction. You can send them all to the same handler if you want, and sort it out there, or send them to different handlers. Here’s one … Read more