touchescancelled is called instead of touchesended
This is not normal behavior. On raising your finger, touchesEnded should be called.
touchesCancelled should be called when your view is removed during touch or a system event happens (e.g. lock the phone while your finger is touching the screen)
See the documentation for touchesEnded and touchesCancelled.
Without your code, it is impossible to tell what is happening. However it seems that even if you manage to get touchedEnded called as it should, you would want to respond to both cases. In swift:
class MyView: UIView {
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
stopGlow()
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
stopGlow()
}
private func stopGlow() {
//Your code here...
}
}
When you touch that view and raise your finger, you should not drag your finger. If you did like that, then touchesCancelled:
method will get called. So I think your view is too small to touch. If yes, then make a big View and try it again. It will work for you then.
Consider this as a comment
..