0

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.

gran33
  • 12,421
  • 9
  • 48
  • 76
sisanared
  • 4,175
  • 2
  • 27
  • 42

2 Answers2

1

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);
}
Community
  • 1
  • 1
gran33
  • 12,421
  • 9
  • 48
  • 76
  • Thats not what I was asking for. It looks like there is no way for me to achieve what I am looking for. Thanks anyway. – sisanared Nov 19 '14 at 04:36
0

You can just call it multiple times like so:

[panGesture requireGestureRecognizerToFail:swipeUp];
[panGesture requireGestureRecognizerToFail:swipeDown];
[panGesture requireGestureRecognizerToFail:swipeLeft];
[panGesture requireGestureRecognizerToFail:swipeRight];
okeanic
  • 11
  • 4