nagarajan
nagarajan

Reputation: 494

Custom multiple gesture on a view

I created two custom gesture recognizer.

  1. PinGestureRecognizer. this gesture is using for drag the view in horizontal direction.
  2. TagGestureRecognizer. this gesture is using for increase the height of the view till user drag the view in vertically.

Now, i want to fail one gesture if another gesture got recognized.

Example:

  1. if user drag the view horizontally in >=10 pixel need to recognized PinGestureRecognizer and fail TapGestureRecognizer and vice versa.

How can i achieve the functionality.

I know iOS7 provide the methods like

If its equal to my problem or not i was not able to understand. if its correct means kindly suggest me to get same functionality in iOS4 and above.

Thanks in advance....

Upvotes: 0

Views: 101

Answers (1)

Mutawe
Mutawe

Reputation: 6524

Use the gestureRecognizerShouldBegin delegate method for the PinGestureRecognizer, for example:

// To handle not scrolling vertically
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer {
    CGPoint translation = [panGestureRecognizer translationInView:myView];
    return fabs(translation.y) < fabs(translation.x);
}

Upvotes: 2

Related Questions