views:

41

answers:

2

I'm diving into iPhone development and I'm trying to get my head around gestures and the touch events. How can I measure how fast the user is moving their finger across the screen of an iOS device using the touche events (touchesBegan, touchesMoved, etc)?

Thanks so much in advance for your help!

+1  A: 

Save time and position of the lasst event and you can calculate the speed (newpos-old) / timediff. The new gesture recognizers have some velocity support as well.

Eiko
+1  A: 

You can do that by using the timestamp property of UITouch class. The property is described as:

The value of this property is the time, in seconds, since system startup the touch either originated or was last changed. You can store and compare the initial value of this attribute to subsequent timestamp values of the UITouch instance to determine the duration of the touch and, if it is being swiped, the speed of movement.

UITouch Class Reference

Shaji