Search code examples
objective-cuiviewuigesturerecognizeruipangesturerecognizeruiswipegesturerecognizer

UIPanGestureRecognizer overlaps UISwipeGestureRecognizer


I have a UIView with a UIPanGestureRecognizer attached to it. I also have an object within the UIView that has multiple UISwipeGestureRecognizers.

The UIPanGestureRecognizer and the UISwipeGestureRecognizers associated with the object overlap.

Is there any way to make the UIPanGestureRecognizer totally ignore a certain area of the UIView or make the object's UISwipeGestureRecognizers take precedence and override the UIView's UIPanGestureRecognizer?


Solution

  • Solved this problem using this delegate method:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
          if ([touch.view isKindOfClass:[UIButton class]] && gestureRecognizer == recognizer) return NO;
          return YES;
    }
    

    Thanks for pointing me in the right direction @MikeS