1

我对 UIGestures 很熟悉,但这种特殊的需求让我碰壁了。

问题:如何找到 UIPinchGesture 的起点和终点?

我必须得到所有这四个点,并且必须在服务器端进行一些计算。

以前有人试过吗?

4

4 回答 4

8

利用

- (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view

喜欢

[gesture locationOfTouch:0 inView:youView]; //first
[gesture locationOfTouch:1 inView:youView]; //second
于 2012-04-25T05:46:34.917 回答
1
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touchPositionOne = [[[event allTouches] allObjects] objectAtIndex:0];
UITouch *touchPositionTwo = [[[event allTouches] allObjects] objectAtIndex:1];
CGPoint fps = [touchPositionOne locationInView:self.imageView];
CGPoint sps = [touchPositionTwo locationInView:self.imageView];

NSLog(@"%@ %@", NSStringFromCGPoint(fps), NSStringFromCGPoint(sps));
}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touchPositionOne = [[[event allTouches] allObjects] objectAtIndex:0];
UITouch *touchPositionTwo = [[[event allTouches] allObjects] objectAtIndex:1];
CGPoint fps = [touchPositionOne locationInView:self.imageView];
CGPoint sps = [touchPositionTwo locationInView:self.imageView];

NSLog(@"%@ %@", NSStringFromCGPoint(fps), NSStringFromCGPoint(sps));
}
于 2012-04-25T12:18:51.303 回答
0
CGPoint point1 = [gestureRecognizer locationOfTouch:0 inView:piece];
CGPoint point2 = [gestureRecognizer locationOfTouch:1 inView:piece];
CGPoint center = [gestureRecognizer locationInView:piece];
于 2013-06-18T08:34:06.753 回答
0

我认为在 XCode 12 中您可以使用 location(ofTouch:, in:) 来识别点的位置:

print(sender.location(ofTouch: 0, in: view))
print(sender.location(ofTouch: 1, in: view))
于 2021-03-05T14:25:52.397 回答