Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get original touch location from UIPanGestureRecognizer

My view has a UIPanGestureRecognizer added to it.
The problem is that by the time the touch is recognized as a pan gesture, it has to be moved a few points, and I can't extract the original touch location at the UIGestureRecognizerStateBegan state. In this state the translationInView: is (0,0), and any subsequent moves are calculated from this point, and not from the original.

Is there a way to extract the original location from the gesture recognizer itself, or do I need to override the touchesBegan: method?

like image 537
antalkerekes Avatar asked Sep 20 '11 01:09

antalkerekes


1 Answers

You should be able to set the delegate for the gesture recogniser and implement

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

to get the initial touch.

like image 102
Sherman Lo Avatar answered Sep 30 '22 03:09

Sherman Lo