Pinch gesture for zoom and pan/tilt

1.4k views Asked by At

How do i use the UIPinchGestureRecognizer for multiple purposes? At the moment i am using it to zoom in/out of my GLKView, but i would like to use the gesture to move around (pan/tilt), but at the same time being able to zoom. I have seen this behaviour in many CAD and 3D App's on iOS.

Code for pinching:

- (void)pinchDetected:(UIPinchGestureRecognizer *)pinchRecognizer
{
    NSLog (@"%@", @"Pinching");

    if (pinchRecognizer.state == UIGestureRecognizerStateBegan ||
        pinchRecognizer.state == UIGestureRecognizerStateChanged ||
        pinchRecognizer.state == UIGestureRecognizerStateEnded) {
        _zoom += (-1)*(logf(pinchRecognizer.scale) * 10.0f);
        pinchRecognizer.scale = 1.0;
    }
}
1

There are 1 answers

2
The iOSDev On BEST ANSWER

Please see this example for more guidance as this example shows what you want to do as it provide all you need to do simultaneous execution of zoom,pan and also tilt see this