0
votes

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.

2

2 Answers

1
votes

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);
}
0
votes

You can just call it multiple times like so:

[panGesture requireGestureRecognizerToFail:swipeUp];
[panGesture requireGestureRecognizerToFail:swipeDown];
[panGesture requireGestureRecognizerToFail:swipeLeft];
[panGesture requireGestureRecognizerToFail:swipeRight];