MAbbas
MAbbas

Reputation: 69

How to detect finger movement direction with iPhone UITouch

The documentation of UITouch mentions that you can get the [B]direction[/B] of finger swiped. But I am unable to find any way/reference how to get the direction information.

I found an old here a version of UITouch class reference that mentions direction information.

But this way does not work for me (I have latest iPhone SDK).

Has anyone of you tried finding direction?

Upvotes: 4

Views: 1659

Answers (1)

David Kanarek
David Kanarek

Reputation: 12613

Apple says you can get it, but in the Event Handling documentation they also explicitly say you have to calculate it. It's not too hard to do though, and there is a sample provided therein. I did it simply by caching the initial touch point, and on touch end ensuring that the touch moved at least 80px in one direction and not more than 75% of the length in the other direction. This gave me good results, but feel free to experiment on what you feel gives the least false positives and negatives.

Upvotes: 3

Related Questions