locationInView是什么意思:对于多指手势识别器意味着什么?

时间:2013-03-05 01:53:57

标签: ios cocoa-touch touch uigesturerecognizer

我正在使用UIRotationGestureRecognizer,并且在目标方法中有以下代码:

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
    UIView *piece = gestureRecognizer.view;
    CGPoint locationInView = [gestureRecognizer locationInView:piece];
    CGPoint locationInSuperview = [gestureRecognizer locationInView:piece.superview];

    piece.layer.anchorPoint = CGPointMake(locationInView.x / piece.bounds.size.width, locationInView.y / piece.bounds.size.height);
    piece.center = locationInSuperview;
}

但是我不太清楚locationInView:返回值表示哪个值,因为应该有两个手指触摸屏幕。

2 个答案:

答案 0 :(得分:2)

locationInView:方法返回两个触摸的中心点。如果您想知道两个单独触摸的位置,请使用locationOfTouch:inView:

答案 1 :(得分:1)