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

UINavigationControllerDelegate make is not work #78

Closed
weixianlove opened this issue Nov 5, 2019 · 2 comments
Closed

UINavigationControllerDelegate make is not work #78

weixianlove opened this issue Nov 5, 2019 · 2 comments

Comments

@weixianlove
Copy link

weixianlove commented Nov 5, 2019

@interface MainNaviVC : UINavigationController
@end
@interface MainNaviVC ()<UINavigationControllerDelegate>
@property (nonatomic, assign) BOOL pushing; //是否正在push

@end

@implementation MainNaviVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isMotionEnabled = YES;
//    self.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
    self.delegate = self;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.pushing) {
        return;
    } else {
        self.pushing = YES;
        NSArray *whiteList = @[NSClassFromString(@"XTAddWebBrowserViewController")]; //可重复push白名单
        
        if (![[super topViewController] isKindOfClass:[viewController class]] || [whiteList containsObject:[viewController class]]) {  // 如果和上一个控制器一样,隔绝此操作
            [super pushViewController:viewController animated:animated];
        }
    }
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    self.pushing = NO;
}

- (void)dealloc {
    self.delegate = nil;
}

while i use UINavigationControllerDelegate, motion not work

@OrkhanAlikhanov
Copy link
Contributor

self.isMotionEnabled = YES;
self.delegate = self;

Should be in reverse order:

self.delegate = self;
self.isMotionEnabled = YES;

@weixianlove
Copy link
Author

I can't push, because this delegate never in

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    self.pushing = NO;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants