用于缩放和平移/倾斜的捏合手势

时间:2012-05-29 15:21:53

标签: ios ios5 uigesturerecognizer uipinchgesturerecognizer

如何将UIPinchGestureRecognizer用于多种用途?目前我用它来放大/缩小我的GLKView,但我想用手势移动(平移/倾斜),但同时能够放大。我在iOS上的许多CAD和3D应用程序中都看到过这种行为。

捏代码:

- (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 个答案:

答案 0 :(得分:2)

请参阅此示例以获取更多指导,因为此示例显示了您要执行的操作,因为它提供了同时执行缩放,平移和倾斜所需的所有操作,请参阅this