添加右滑返回
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#import "BaseNavigationController.h"
|
#import "BaseNavigationController.h"
|
||||||
|
|
||||||
@interface BaseNavigationController ()
|
@interface BaseNavigationController () <UIGestureRecognizerDelegate>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@
|
|||||||
if (@available(iOS 14.0, *)) {
|
if (@available(iOS 14.0, *)) {
|
||||||
self.navigationBar.topItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
|
self.navigationBar.topItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统一开启“边缘右滑返回”(interactivePopGestureRecognizer 在自定义导航栏/隐藏系统导航栏场景下可能失效)
|
||||||
|
if (self.interactivePopGestureRecognizer) {
|
||||||
|
self.interactivePopGestureRecognizer.delegate = self;
|
||||||
|
self.interactivePopGestureRecognizer.enabled = YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
|
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
|
||||||
@@ -41,6 +47,15 @@
|
|||||||
[super pushViewController:viewController animated:animated];
|
[super pushViewController:viewController animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - UIGestureRecognizerDelegate
|
||||||
|
|
||||||
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
||||||
|
if (gestureRecognizer == self.interactivePopGestureRecognizer) {
|
||||||
|
return self.viewControllers.count > 1;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
/// Push 一个 VC,若栈中已存在相同 class 的 VC,则先移除旧的再 push 新的。
|
/// Push 一个 VC,若栈中已存在相同 class 的 VC,则先移除旧的再 push 新的。
|
||||||
- (void)kb_pushViewControllerRemovingSameClass:(UIViewController *)viewController
|
- (void)kb_pushViewControllerRemovingSameClass:(UIViewController *)viewController
|
||||||
animated:(BOOL)animated {
|
animated:(BOOL)animated {
|
||||||
|
|||||||
Reference in New Issue
Block a user