Phil
Phil

Reputation: 461

Pan and 2 Finger Pinch simultaneous iOS -at the same time-

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

Upvotes: 10

Views: 5271

Answers (2)

Stuart
Stuart

Reputation: 37053

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.

Upvotes: 15

deanWombourne
deanWombourne

Reputation: 38475

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!

Upvotes: 0

Related Questions