0

我正在寻找的最终位置touchesEnded。我的touchesBegan代码如下所示:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
   if let touch = touches.first {
       touchStart = touch.locationInNode(self)
       print("touchStart_1: \(touchStart)")
   }
}

印刷品给了我位置。

touchesEnded中,我有以下内容:

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
  if let touch = touches.first, start = touchStart {
    print("touchStart_2: \(touchStart)")
    let location = touch.locationInNode(self)
    print("touchEnded: \(location)")
  }
}

这些印刷品都没有返回任何东西。作为附加信息,我UISwipeGestureRecognizer也在其他地方使用,但我知道手势识别器独立于触摸工作。知道怎么了?

4

1 回答 1

0

设置这 2 个手势属性:

let swipeGesturte: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "swipeAction:")
swipeGesturte.direction = UISwipeGestureRecognizerDirection.Right
swipeGesturte.cancelsTouchesInView = false // 1.
swipeGesturte.delaysTouchesEnded = false // 2.
self.view.addGestureRecognizer(swipeGesturte)

有关cancelsTouchesInView的更多信息:调用 setCancelsTouchesInView 时会发生什么?

于 2016-01-26T10:15:50.487 回答