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

2 Gesture Recognition Device:

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 the pinch and pan at the same time do not work ... often I can pinch, because the pan recognizer is turned on.

considers

+5
source share
2 answers

It doesn't seem like you assign a delegate to each gesture recognizer. gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:- This is the delegate method, so if the gesture recognizer does not have a delegate, this method will not be called.

As a result, the return value will be by default NO, and therefore gestures will not be recognized at the same time.

+10
source

-?

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

PS !

0

All Articles