Pinch and rotation gesture simultaneously

I wanted to set both UIPinchGestureRecognizer and UIRotationGestureRecognizer to one view. I just made both objects and add ‘addGestureRecognizer:’ to the view. Yes, this worked. I was able to zoom in/out and rotate the view, BUT I had to release my fingers from the screen after one gesture finished. I was not able to zoom in/out and rotate a target simultaneously.

Well, this means I have to write code to find two touched points and calculate from their relative positions…?

I found next method of UIGestureRecognizerDelegate in the reference,
- (BOOL)gestureRecognizer:(UIGestureRecognizer * _Nonnull)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer * _Nonnull)otherGestureRecognizer
I just added this method and made this return YES, and it worked as I expected!
This is not a new method(available in iOS 3.2 and later) at all, but I didn’t know this.

Develop | Comments(1) | Trackback(0)
Comment is pending approval.
Comment is pending blog author's approval.