0

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?

Hamish
  • 78,605
  • 19
  • 187
  • 280
Prientus
  • 733
  • 6
  • 15

1 Answers1

2

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.

Carl Lindberg
  • 2,902
  • 18
  • 22
  • this feels like a comment as it currently is. I suggest you edit it to make it more answer-y, explaining to the OP when `touchesCancelled` gets called, and why `touchesEnded` isn't getting called in his situation. – Hamish Feb 14 '16 at 13:52
  • Excellent point. Handling it in both is what did the trick. Thank you – Prientus Apr 12 '16 at 16:16