Question

I want to get a callback when my UIPinchGestureRecognizer finished a pinch-gesture. Moreover it would be great to know if the finished gesture was a zoom in or a zoom out.

Does anyone know a method to use? Or the approach to do?

Thanks!

Was it helpful?

Solution

Another approach instead of overriding touchesEnded:, is that you could just check the state of the gesture recognizer in your target handler method.

  -(void)handlePinchGesture:(UIGestureRecognizer*)gestureRecognizer {    
    if(UIGestureRecognizerStateEnded == [gestureRecognizer state]){
      // do something
    }
  }

OTHER TIPS

You can know if it was a zoom in or out by the scale property of the UIPinchGestureRecognizer.

Just overrride it's touchesEnded: method to get a callback (and the call some other method if you wish).

The best approach which does not require subclassing is to examine the "state" property on the gesture recognized instance in your action handler. The state will change during all phases of the lifecycle of the gesture. The state change you're looking for is UIGestureRecognizerStateEnded. It is also good practice to check for UIGestureRecognizerStateCancelled as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top