I would recommend trying to use touchesCancelled
function as it is called when the system considers your tap as a cancelled one (for instance, when you drag a finger before raising it as answered here: touchescancelled is called instead of touchesended)