【发布时间】:2015-12-22 13:58:03
【问题描述】:
我在 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? -
是的,在
viewDidLoad我有view.multipleTouchEnabled = true。
标签: ios swift uiview uitouch uievent