2013-03-10 110 views
2

我有一個UILongPressGestureRecognizer設置與numberOfTouchesReguired = 2。如何獲得視圖上每個手指的連續座標?從UILongPressGestureRecognizer的每個觸摸獲取座標

目前我有這個,但它似乎將所有觸摸的位置合併爲1個座標。

 
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender { 
    CGPoint locationInView = [sender locationInView:nil]; 
}
+0

@Till長按會隨着手指移動發送連續事件。 – rmaddy 2013-03-10 01:52:27

+0

@rmaddy我不好,你說得對。另外,允許的移動距離是可配置的。 – Till 2013-03-10 01:53:19

回答

8

查看文檔UIGestureRecognizer。它提供了這樣的方法:

- (void)handleLongPress:(UILongPressGestureRecognizer *)sender { 
    if (sender.state == UIGestureRecognizerStateChanged) { 
     NSUInteger *touchCount = [sender numberOfTouches]; 
     for (NSUInteger t = 0; t < touchCount; t++) { 
      CGPoint point = [sender locationOfTouch:t inView:sender.view]; 
     } 
    } 
+0

謝謝,剛剛也找到了。 – thisiscrazy4 2013-03-10 01:53:35