0

it means user can't pan and pinch simultaneously and pinch gesture stops pan one.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

    return YES;
}

This code is not working for me because it makes these gestures working simultaneously.

By default if I don't use this code then pan gesture stops pinch one but I need the opposite thing.

Updated

@interface SomeClass : UIViewController <UIGestureRecognizerDelegate>

...

@end

@implementation SomeClass

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

        return YES;
    }

@end
user2083364
  • 744
  • 1
  • 7
  • 20
  • Are you setting this in one of the delegates, or in both of them? You should do this as the delegate of the pinch recognizer, not both. – Sergey Kalinichenko Aug 12 '13 at 13:17
  • I have updated the code. But if I do as you write then pinch sometimes will work with pan gesture simultaneously. But I need only one working gesture at the same time – user2083364 Aug 12 '13 at 13:27

2 Answers2

1

You can create dependencies between recognizers using the requireGestureRecognizerToFail: method so that one gesture will only become eligible to begin when another has failed.

Depending on exactly what you need you may have to subclass and create your own gestures so that you can control how and when they begin and fail.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • I have already tried this method but it doesn't work properly. Pan gesture works as usually but handles only its touch up event – user2083364 Aug 12 '13 at 13:35
1

solved by editing pan gesture handler:

- (IBAction)panGRUsed:(id)sender {

    UIPanGestureRecognizer *gr = (UIPanGestureRecognizer *)sender;
    if (gr.numberOfTouches > 1) {

        [gr setTranslation:CGPointZero inView:self.view];
    } else {

        ...
    }
}
user2083364
  • 744
  • 1
  • 7
  • 20