From cb4ae389a59317c229ab8ee015a263923337d34f Mon Sep 17 00:00:00 2001 From: Frank Fleschner Date: Tue, 10 Jun 2014 15:59:57 -0500 Subject: [PATCH] Added delegate method to be able to control the gesture recognizers being able to play nice with other gesture recognizers. --- SWRevealViewController/SWRevealViewController.h | 6 ++++++ SWRevealViewController/SWRevealViewController.m | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/SWRevealViewController/SWRevealViewController.h b/SWRevealViewController/SWRevealViewController.h index b9187f4..0a00920 100755 --- a/SWRevealViewController/SWRevealViewController.h +++ b/SWRevealViewController/SWRevealViewController.h @@ -286,6 +286,12 @@ typedef enum // Implement this to return NO when you want the tap gesture recognizer to be ignored - (BOOL)revealControllerTapGestureShouldBegin:(SWRevealViewController *)revealController; +// Implement this to return YES if you want this gesture recognizer to share touch events with the pan gesture +- (BOOL)revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer; + +// Implement this to return YES if you want this gesture recognizer to share touch events with the tap gesture +- (BOOL)revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer; + // Called when the gestureRecognizer began and ended - (void)revealControllerPanGestureBegan:(SWRevealViewController *)revealController; - (void)revealControllerPanGestureEnded:(SWRevealViewController *)revealController; diff --git a/SWRevealViewController/SWRevealViewController.m b/SWRevealViewController/SWRevealViewController.m index ff34615..4582cda 100755 --- a/SWRevealViewController/SWRevealViewController.m +++ b/SWRevealViewController/SWRevealViewController.m @@ -1075,6 +1075,21 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)recognizer return NO; } +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + if ( gestureRecognizer == _panGestureRecognizer ) + { + if ( [_delegate respondsToSelector@selector(revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) + return [_delegate revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; + } + if ( gestureRecognizer == _tapGestureRecognizer ) + { + if ( [_delegate respondsToSelector@selector(revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) + return [_delegate revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; + } + + return NO; +} - (BOOL)_tapGestureShouldBegin {