Search code examples
iosuiscrollviewuigesturerecognizeruipinchgesturerecognizer

Can I pass a pinch gesture recognizer to a ScrollView to have it zoom?


I wrote a custom pinch gesture recognizer for my ScrollView's zooming, and I handle pinch touches in a method in my view controller.

But in some cases, I want the ScrollView to behave exactly as it would normally behave (if it used the standard pinch gesture recognizer that comes with ScrollView).

Is there some way that in such cases I can pass my custom gesture recognizer to the ScrollView and it would use that recognizer to scale the view as it normally would?

Could I pass the gesture recognizer to the selector that is triggered by pinch actions?


Solution

  • I have not tried this, but here's an idea:

    When you set your own gestureRecognizer, store the ScrollView's pinchGestureRecognizer in an iVar. You should then be able to dynamically exchange your gestureRecognizer and the original one.