In my project, I have the main view, in which I add a UITapGestureRecognizer
, and inside this main view, I have a subview that is a custom UIControl
, which I will call UICustomButton
.
The UICustomButton
overrides the following methods of UIControl
:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
pressAnimation()
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
releaseAnimation()
listener?.onClick(sender: self)
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
releaseAnimation()
}
The problem I am having is, all "click touches" are hitting the following callbacks:
touchesBegan
touchesCancelled
The touchesEnded
callback is not being called, it's kinda being ignored and I don't know why.
How can I make touchesEnded
be called instead of touchesCancelled
on a touch action?
Some facts:
- if I remove the
UITapGestureRecognizer
from the parent view, everything works fine; - even not calling the
supers
and overriding alltouches
methods, thetouchesCancelled
is called =/; - if I do a "long touch" or do a "big moving gesture",
touchesEnded
is called :o.