I am implementing touchesBegan
and touchesEnded
in my iOS application trying to detect when the user puts a finger on the screen and when he releases it.
The problem I am having is that as soon as touchesBegan
gets called, if the user rotates the device while still holding his finger on the screen, when he lets go of the screen, touchesEnded
does not get called.
Does anyone know why this might be happening?
Are you getting touchesCancelled instead?
In general, the system will call either touchesEnded
or touchesCancelled
after a touchesBegan
, so code should deal with both. Touches can be cancelled for various reasons, such as a gesture recognizer taking over, an non-interactive animation starting on the view, an incoming phone call, etc.