Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

尝试修改当拦截系统手势时,崩溃 #280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RTRootNavigationController/Classes/RTRootNavigationController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIGestureRecognizerDelegate> interactivePopGestureRecognizerDelegate;

/*!
* @brief use system original back bar item or custom back bar item returned by
* @c -(UIBarButtonItem*)customBackItemWithTarget:action: , default is NO
Expand Down
63 changes: 44 additions & 19 deletions RTRootNavigationController/Classes/RTRootNavigationController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Empty file.
Empty file.