1

我正在使用一个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:返回值表示哪个值,因为应该有两根手指触摸屏幕。

4

2 回答 2

2

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

于 2013-03-05T01:58:06.690 回答
2

阅读文档是个好主意:

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html

它是多次触摸的“质心”。

于 2013-03-05T02:05:57.680 回答