我在 ViewController 中有两个 View ,它们在按下时执行特定的操作。如果我用一根手指按住其中一个并用另一根手指触摸相同的 View ,则什么也不会发生。下面的“ok”测试没有出现。
我覆盖方法 touchesBegan
来执行操作:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("ok")
if let touch = touches.first{
let viewTag = touch.view!.tag
if viewTag == 101 {
// my action for view 1
} else if viewTag == 102 {
// my action for view 2
}
}
super.touchesBegan(touches, withEvent: event)
}
编辑
我已经在使用 multipleTouchEnabled = true
最佳答案
您必须在您的 View 上启用多点触控:
self.view.multipleTouchEnabled = true;
关于ios - 当 View 已经被按下时如何响应触摸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417540/