UISwipeGestureRecognizer Gesture Starting Point

Is it possible to get the starting point of gestures from UISwipeGestureRecognizer. how is this possible in

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch * touch = [touches anyObject]; gestureStartPoint = [touch locationInView:self]; } 
+4
source share
3 answers

According to the UISwipeGestureRecognizer documentation, you can:

You can determine where the swipe started by calling the UIGestureRecognizer methods locationInView: and locationOfTouch: inView :. The first method gives you a centroid if more than one touch was involved in the gesture; the latter gives the location of a particular touch.

PS: you really should first look at the documentation, the answer was in the link of the UISwipeGestureRecognizer class, not hard to find. Part of being a developer can look at things, Apple has excellent documentation, use it!

+8
source

Attention

Ami's answer is completely WRONG! A Recognizer can generate a UIGestureRecognizerStateBegan , but with a UISwipeGestureRecognizer , only the UIGestureRecognizerStateEnded event is UIGestureRecognizerStateEnded .

But instead, touchesBegan: works. The problem is that if it supports user interaction, then it only works for the current view, and you need to pass it to the parent view.

+3
source

Yes it is possible. See the following code:

 if ([recognizer state] == UIGestureRecognizerStateBegan || [recognizer state] != UIGestureRecognizerStateChanged) { NSLog(@"StateBegan :::::"); } 
0
source

All Articles