我在ViewController中有兩個視圖,它們在接觸時執行特定的操作。如果我用一根手指按住其中一隻手,並用另一隻手指觸摸同一視圖,則什麼也不會發生。下面的「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
是'multipleTouchEnabled'屬性設置爲TRUE;? – ZhangChn
是的,在'viewDidLoad'我有'view.multipleTouchEnabled = true'。 – msampaio