diff --git a/RTRootNavigationController/Classes/RTRootNavigationController.h b/RTRootNavigationController/Classes/RTRootNavigationController.h old mode 100644 new mode 100755 index 1048199..afaf81d --- a/RTRootNavigationController/Classes/RTRootNavigationController.h +++ b/RTRootNavigationController/Classes/RTRootNavigationController.h @@ -58,6 +58,13 @@ self.window.rootViewController = [[RTRootNavigationController alloc] initWithRoo IB_DESIGNABLE @interface RTRootNavigationController : UINavigationController + +/*! +* @brief intercept system PopGestureRecognizer to realize something you want +* @warning set it when showing ViewController viewWillAppear: or viewDidAppear: , make it nil when the target ViewController viewWillDisappear: or viewDidDisappear: +*/ +@property (nonatomic, weak) id interactivePopGestureRecognizerDelegate; + /*! * @brief use system original back bar item or custom back bar item returned by * @c -(UIBarButtonItem*)customBackItemWithTarget:action: , default is NO diff --git a/RTRootNavigationController/Classes/RTRootNavigationController.m b/RTRootNavigationController/Classes/RTRootNavigationController.m old mode 100644 new mode 100755 index 61cdc14..f97c6b5 --- a/RTRootNavigationController/Classes/RTRootNavigationController.m +++ b/RTRootNavigationController/Classes/RTRootNavigationController.m @@ -812,19 +812,6 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation return self.topViewController.preferredInterfaceOrientationForPresentation; } -- (BOOL)respondsToSelector:(SEL)aSelector -{ - if ([super respondsToSelector:aSelector]) { - return YES; - } - return [self.rt_delegate respondsToSelector:aSelector]; -} - -- (id)forwardingTargetForSelector:(SEL)aSelector -{ - return self.rt_delegate; -} - #pragma mark - Public Methods - (UIViewController *)rt_topViewController @@ -1046,14 +1033,52 @@ - (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPr #pragma mark - UIGestureRecognizerDelegate -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer -{ - return (gestureRecognizer == self.interactivePopGestureRecognizer); +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizerShouldBegin:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizerShouldBegin:gestureRecognizer]; + } else { + return YES; + } +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; + } else { + return (gestureRecognizer == self.interactivePopGestureRecognizer); + } } -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer -shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { - return (gestureRecognizer == self.interactivePopGestureRecognizer); +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizer:gestureRecognizer shouldRequireFailureOfGestureRecognizer:otherGestureRecognizer]; + } else { + return NO; + } +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizer:gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer]; + } else { + return (gestureRecognizer == self.interactivePopGestureRecognizer); + } +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizer:shouldReceiveTouch:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch]; + } else { + return YES; + } +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press { + if (self.interactivePopGestureRecognizerDelegate && [self.interactivePopGestureRecognizerDelegate respondsToSelector:@selector(gestureRecognizer:shouldReceivePress:)]) { + return [self.interactivePopGestureRecognizerDelegate gestureRecognizer:gestureRecognizer shouldReceivePress:press]; + } else { + return YES; + } } @end diff --git a/RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.h b/RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.h old mode 100644 new mode 100755 diff --git a/RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.m b/RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.m old mode 100644 new mode 100755