From 6aeb099d5d40d92562acf6ba71fd8564c2c5bec7 Mon Sep 17 00:00:00 2001 From: Mauro Piccini Date: Sun, 18 Oct 2015 16:25:43 +0200 Subject: [PATCH] stop unwanted gesture recogniser Pan gesture recogniser should not begin if the corresponding menu is not enabled in top view controller --- SlideMenu/Source/SlideNavigationController.m | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 9a09650..0617cfa 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -720,6 +720,27 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceive : NO; } + +-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { + + // if menu is open, then let it close + if (self.horizontalLocation != 0) + return YES; + + if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { + UIPanGestureRecognizer *aPanRecognizer = (UIPanGestureRecognizer *)gestureRecognizer; + CGPoint translation = [aPanRecognizer translationInView:aPanRecognizer.view]; + Menu currentMenu = (translation.x > 0) ? MenuLeft : MenuRight; + + if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController]) { + return NO; + } + } + + return YES; +} + + - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer { CGPoint translation = [aPanRecognizer translationInView:aPanRecognizer.view];