How to lift a finger from a touch screen without generating touch events?

StackOverflow https://stackoverflow.com/questions/18867038

  •  29-06-2022
  •  | 
  •  

Вопрос

I'm writing an application where the user moves shapes on a screen by dragging them, using a UIPanGestureRecognizer.

Here is the problem: the finger is not a point, and the location of the UITouch is more or less the centroid of the contact surface of the finger on the screen. When the user begins to lift his finger, the shape of the contact surface changes and it generates additional touch events before the finger actually leaves the screen.

How to deal with this? I could try to detect a pause in the movement of the finger, but I don't know if this feels intuitive. Are there any other solutions ?

Это было полезно?

Решение

Just an idea: I suppose you could add a 0.2 second delay between touch detection and actually moving the shape. That way, you can discard the bogus touch events after the user lifts his finger (which is far shorter than 0.2 seconds).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top