Tono Nam
Tono Nam

Reputation: 36070

Make UIRotationGestureRecognizer more sensible

I have added the following gesture recognizer to my user control:

UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc]
          initWithTarget:self
          action:@selector(ViewRotated:)];
[[self view] addGestureRecognizer:rotate];

-(void)ViewRotated:(UIRotationGestureRecognizer *)sender{
    NSLog(@"rotated");
}

so far everything works great and the gesture responds fast whenever I rotate my fingers on the iOS device.


Now the problem comes when adding the pinch gesture recognizer to the same view. When I add:

 UIPinchGestureRecognizer* pch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(ViewPinched:)];
[[self view] addGestureRecognizer:pch];
//...
// ...

-(void)ViewPinched:(UIPinchGestureRecognizer *)sender{
     NSLog(@"Pinched");
}

that pch event fires 70% of the time. I have to really rotate my fingers in a perfect way so that the rotate gesture triggers instead of the pinch one. How can I make the rotate gesture more sensible so that it triggers more easily?

Upvotes: 0

Views: 743

Answers (1)

omz
omz

Reputation: 53561

You can set the gesture recognizers' delegate and return YES from gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method. This allows multiple gesture recognizers to work simultaneously.

Upvotes: 4

Related Questions