我正在寻找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
,但据我所知,手势识别器的工作与触摸无关。知道了什么?
答案 0 :(得分: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 的更多信息:What really happens when call setCancelsTouchesInView?