UIView中的UIPinchGestureRecognizer无法正常工作

时间:2016-08-08 13:47:01

标签: ios objective-c uiview uipinchgesturerecognizer

我正在尝试使用UIViewUIPinchGestureRecognizer中进行放大和缩小。但是当我在我的触控板上捏时,它无法识别捏并且控件不会进入我的twoFingerPinch功能。我使用以下代码。

- (void)viewDidLoad {
//.......
UIPinchGestureRecognizer *twoFingerPinch = [[UIPinchGestureRecognizer alloc]
                      initWithTarget:self
                      action:@selector(twoFingerPinch:)];
    [myview addGestureRecognizer:twoFingerPinch];
//.....
}

- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
    NSLog(@"Pinch scale: %f", recognizer.scale);
    if (recognizer.scale >1.0f && recognizer.scale < 2.5f) {
        CGAffineTransform transform = CGAffineTransformMakeScale(recognizer.scale, recognizer.scale//);
        myview.transform = transform;
    }
}

为什么它没有识别触控板上的夹点?有没有其他方法可以做同样的事情?

2 个答案:

答案 0 :(得分:3)

首先单击“选项”按钮。您将获得2个灰色斑点,您可以使用鼠标或触控板移动它们。在旧版本中,您需要按shift +选项。

了解更多详情,请查看this

答案 1 :(得分:1)

确保select regexp_replace( 'margin=x;margin=y;margin=z;', '.*?=(.*?);.*', '\1', 1 -- occurrences. I thought that picking 1, 2 or 3 would solve my problem? ) from dual; -- This returns "xyz", which is terrible. I was expecting it to return "x", in this case. 的{​​{1}}设置为userInteractionEnabled

yes