geminiCoder
geminiCoder

Reputation: 2906

How to set up 2 UISwipeGestureRecognizer

I am looking for a way of having UISwipeGestureRecognizers added to 1 view. One that detects Downward swipes and one for right swipes. I have come across similar questions on SE, however they don't solve my problem.

I currently have

 swipeGest = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(respondToSwipe:)];
[swipeGest setDirection:UISwipeGestureRecognizerDirectionDown];
[swipeGest setNumberOfTouchesRequired:1];
[swipeGest setDelegate:self];
[self.viewAnimation addGestureRecognizer:swipeGest];

and

    sideSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(sideSwipe:)];
[swipeGest setDirection:UISwipeGestureRecognizerDirectionRight];
[swipeGest setNumberOfTouchesRequired:1];
[sideSwipe setDelegate:self];
[self.viewAnimation addGestureRecognizer:sideSwipe];

What happens is the second sideSwipe recogniser overrides the first one. I tried using the delegate methods as suggested in another thread but have been unsuccessful. Has anyone successfully done this if? so I would be grateful for a pointer.

Upvotes: 0

Views: 130

Answers (1)

nhahtdh
nhahtdh

Reputation: 56809

The 2nd and 3rd line of right swipe is using swipeGest, it should be sideSwipe

Looks like copy paste error.

Upvotes: 2

Related Questions