Skip to content

Commit

Permalink
修复UINavigationController拓展方法forceEnableInteractivePopGestureRecognize…
Browse files Browse the repository at this point in the history
…r的Bug
  • Loading branch information
zhoon committed Apr 7, 2017
1 parent cd4d8a6 commit f6038c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion QMUIKit/UIKitExtensions/UINavigationController+QMUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/// 是否可以`popViewController`,可以在这个返回里面做一些业务的判断,比如点击返回按钮的时候,如果输入框里面的文本没有满足条件的则可以弹alert并且返回NO
- (BOOL)canPopViewController;

/// 当自定义了`leftBarButtonItem`按钮之后,系统的手势返回就失效了。可以通过`forceEnableInteractivePopGestureRecognizer`来决定要不要把那个手势返回强制加回来
/// 当自定义了`leftBarButtonItem`按钮之后,系统的手势返回就失效了。可以通过`forceEnableInteractivePopGestureRecognizer`来决定要不要把那个手势返回强制加回来。当 interactivePopGestureRecognizer.enabled = NO 或者当前`UINavigationController`堆栈的viewControllers小于2的时候此方法无效。
- (BOOL)forceEnableInteractivePopGestureRecognizer;

@end
Expand Down
4 changes: 3 additions & 1 deletion QMUIKit/UIKitExtensions/UINavigationController+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceive
if ([originGestureDelegate respondsToSelector:@selector(gestureRecognizer:shouldReceiveTouch:)]) {
// 先判断要不要强制开启手势返回
UIViewController *viewController = [self topViewController];
if ([viewController respondsToSelector:@selector(forceEnableInteractivePopGestureRecognizer)] &&
if (self.viewControllers.count > 1 &&
self.interactivePopGestureRecognizer.enabled &&
[viewController respondsToSelector:@selector(forceEnableInteractivePopGestureRecognizer)] &&
[viewController forceEnableInteractivePopGestureRecognizer]) {
return YES;
}
Expand Down

0 comments on commit f6038c6

Please sign in to comment.