すべての種類のビューに対してUITapGestureRecognizer
を実装することで回避策を試すことができます。
override func viewDidLoad(){
super.viewDidLoad()
let tapRecognizer = UITapGestureRecognizer(target: view, action: "handleSingleTap:")
tapRecognizer.numberOfTapsRequired = 1
self.view.addGestureRecognizer(tapRecognizer)
}
func handleSingleTap(recognizer: UITapGestureRecognizer) {
//Do something here with the gesture
}
タッチの開始とタッチの終了については、ネイティブメソッドをオーバーライドしてそのコードを試してください。
override func touchesBegan(touches: Set, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
let touch: UITouch = touches.first as! UITouch
if (touch.view == yourView){
println("touchesBegan | This is an ImageView")
}else{
println("touchesBegan | This is not an ImageView")
}
}
touchendfunc。あなたが前に試してみましたかを示すことができ
override func touchesEnded(touches: Set, withEvent event: UIEvent) {
super.touchesMoved(touches, withEvent: event)
let touch: UITouch = touches.first as! UITouch
if (touch.view == yourView){
printing("touchesEnded | This is an ImageView")
}
else{
println("touchesEnded | This is not an ImageView")
}
}
.. – vaibhav