Pinch & Rotate: UIGestureRecognizerDelegate not called

I am trying to implement both a pinch and a rotation in one view. Sometimes a pinch selector is selected, and sometimes a rotary, well, but then he sticks to it. The problem is that gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer not called. Why not? You have to be something obvious ...

 @interface FaceView : UIView <UIGestureRecognizerDelegate> { } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer; @end @implementation FaceView - (id)initWithFrame:(CGRect)frame { if( self = [super initWithFrame:frame] ) { self.multipleTouchEnabled = YES; self.userInteractionEnabled = YES; UIRotationGestureRecognizer* rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGesture:)]; [self addGestureRecognizer:rotationRecognizer]; [rotationRecognizer release]; UIPinchGestureRecognizer* pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)]; [self addGestureRecognizer:pinchRecognizer]; [pinchRecognizer release]; } return self; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { NSLog(@"gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer"); return YES; } - (void)rotationGesture:(UIRotationGestureRecognizer*)gesture { switch( gesture.state ) { case UIGestureRecognizerStateBegan: NSLog(@"rotationGesture began"); break; case UIGestureRecognizerStateChanged: NSLog(@"rotationGesture changed"); break; } } - (void)pinchGesture:(UIPinchGestureRecognizer*)gesture { switch( gesture.state ) { case UIGestureRecognizerStateBegan: NSLog(@"pinchGesture began"); break; case UIGestureRecognizerStateChanged: NSLog(@"pinchGesture changed"); break; } } .... 
+4
source share
1 answer

I had to set rotationRecognizer.delegate = self; and pinchRecognizer.delegate = self;

+16
source

All Articles