8

2 Gesture recognizer:

UIPinchGestureRecognizer *twoFingerPinch = 
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[croppper addGestureRecognizer:twoFingerPinch];

UIPanGestureRecognizer *PanRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)] autorelease];
[croppper addGestureRecognizer:PanRecognizer];

and:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {        
    return YES;
}   

But pinch and pan at the same time is not working... often i can pinch because the pan recognizer is on.

regards

Phil
  • 341
  • 6
  • 19

2 Answers2

14

It doesn't look like you're setting the delegate for each gesture recognizer. gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: is a delegate method, and so if the gesture recognizer has no delegate, this method won't be invoked.

As a result, the default return value will be NO, and so the gestures won't be recognised simultaneously.

Stuart
  • 36,683
  • 19
  • 101
  • 139
  • 3
    +1 for correct answer. In other words, add the following two lines to your code: `twoFingerPinch.delegate = self;` and `PanRecognizer.delegate = self;`. Also consider renaming the second gestureRecognizer to use a lowercase initial. – Till Dec 06 '11 at 16:54
  • your right! thank you! (twoFingerPinch.delegate = self;) i – Phil Dec 06 '11 at 16:58
  • 3
    Stupid web cache - now my answer looks ridiculous :( – deanWombourne Dec 06 '11 at 17:12
0

Are you setting yourself as the recognisers delegate?

[twoFingerPinch setDelgate:self];
...
[PanRecognizer setDelegate:self];

PS I'd also try to get a more consistent naming scheme for your variables!

deanWombourne
  • 38,189
  • 13
  • 98
  • 110