代码之家  ›  专栏  ›  技术社区  ›  srikanth rongali

触摸移动:带事件

  •  1
  • srikanth rongali  · 技术社区  · 15 年前

    我得到了touchebegan和touchesened的坐标。 但是在touchemoved中,我能得到从touchebegan到touchesened的所有触摸坐标吗? 我的意思是当我把手指放在屏幕上,拖到某个位置,然后把它举起来。 那么,我能得到从开始位置到结束位置的所有坐标吗? 如果可能的话,我怎样才能拿到?

    1 回复  |  直到 15 年前
        1
  •  5
  •   rein    15 年前

    触摸移动时,只要触摸上有移动,就会调用TouchsMoved。如果需要所有点的数组,则每次调用TouchsMoved时都需要将它们添加到可变数组中。

    - (void) touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
        CGPoint tappedPt = [[touches anyObject] locationInView: self];
        int     xPos = tappedPt.x;
        int     yPos = tappedPt.y;
        // do something with xPos and yPos like add them to an array
    }