Ronald Hofmann
Ronald Hofmann

Reputation: 1430

UISwipeGestureRecognizer left direction not recognized

I´m using a UISwipeGestureRecognizer on an UIButton which is
connected to an IBAction handleSwipe:

- (IBAction) handleSwipe:(UISwipeGestureRecognizer*) swipeRecognizer {
 NSLog(@"handleSwipe: %i",[swipeRecognizer direction]);
}

Unfortunately only right swipes are recognized. I don´t see any settings to limit the swipes to left or right. Any ideas?

Upvotes: 2

Views: 815

Answers (1)

Vangaorth
Vangaorth

Reputation: 670

The setting you mentioned is the direction property, introduced on iOS 3.2. To recognise left and right swipe just do

swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight;

where swipeGestureRecognizer is your instance of UISwipeGestureRecognizer.

Upvotes: 1

Related Questions