From e3d35e1ac469998cc56fb15011283b7805e3c065 Mon Sep 17 00:00:00 2001 From: EShow Date: Fri, 17 Jan 2020 18:21:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E6=94=B9=E5=BD=93?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E7=B3=BB=E7=BB=9F=E6=89=8B=E5=8A=BF=E6=97=B6?= =?UTF-8?q?,=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Classes/RTRootNavigationController.h | 7 +++ .../Classes/RTRootNavigationController.m | 63 +++++++++++++------ ...iewController+RTRootNavigationController.h | 0 ...iewController+RTRootNavigationController.m | 0 4 files changed, 51 insertions(+), 19 deletions(-) mode change 100644 => 100755 RTRootNavigationController/Classes/RTRootNavigationController.h mode change 100644 => 100755 RTRootNavigationController/Classes/RTRootNavigationController.m mode change 100644 => 100755 RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.h mode change 100644 => 100755 RTRootNavigationController/Classes/UIViewController+RTRootNavigationController.m 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