Reputation: 4287
I have all 4 Swipe gestures registered for my view (Swipe up, down, left and right). I would also like to use the Pan gesture for the same view, but requireGestureRecognizerToFail
allows me to specify only one of the Swipe gestures.
Is there a way to do something like this:
[panGesture requireGestureRecognizersToFail: @[swipeUp, swipeDown, swipeLeft, swipeRight]];
Thank you.
Upvotes: 0
Views: 566
Reputation: 11
You can just call it multiple times like so:
[panGesture requireGestureRecognizerToFail:swipeUp];
[panGesture requireGestureRecognizerToFail:swipeDown];
[panGesture requireGestureRecognizerToFail:swipeLeft];
[panGesture requireGestureRecognizerToFail:swipeRight];
Upvotes: 0
Reputation: 12981
First, Take a brief look at this link
If I get u right, u want pan gesture, so:
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:myView
action:@selector(handlePan:)];
[myView addGestureRecognizer: panGesture];
Then, in handlePan:
u should:
- (void) handlePan:(UIPanGestureRecognizer *)panGestureRecognizer
{
CGPoint translation = [uiPanGestureRecognizer translationInView:self.superview];
myView.center = CGPointMake(lastLocation.x + translation.x,
lastLocation.y + translation.y);
}
Upvotes: 1