From cb4ae389a59317c229ab8ee015a263923337d34f Mon Sep 17 00:00:00 2001 From: Frank Fleschner Date: Tue, 10 Jun 2014 15:59:57 -0500 Subject: [PATCH 1/2] 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 { From 11e1ec59346431db2623313f14a1fa04411d6643 Mon Sep 17 00:00:00 2001 From: Frank Fleschner Date: Tue, 10 Jun 2014 17:15:17 -0500 Subject: [PATCH 2/2] Fixed a typo, changed the style to more reflect the project. --- SWRevealViewController/SWRevealViewController.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SWRevealViewController/SWRevealViewController.m b/SWRevealViewController/SWRevealViewController.m index 4582cda..6403981 100755 --- a/SWRevealViewController/SWRevealViewController.m +++ b/SWRevealViewController/SWRevealViewController.m @@ -1079,13 +1079,15 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni { if ( gestureRecognizer == _panGestureRecognizer ) { - if ( [_delegate respondsToSelector@selector(revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) - return [_delegate revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; + if ( [_delegate respondsToSelector:@selector(revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) + if ( [_delegate revealControllerPanGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer] == YES ) + return YES; } if ( gestureRecognizer == _tapGestureRecognizer ) { - if ( [_delegate respondsToSelector@selector(revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) - return [_delegate revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; + if ( [_delegate respondsToSelector:@selector(revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:)] ) + if ( [_delegate revealControllerTapGestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer] == YES ) + return YES; } return NO;