写项目遇到需要在支付成功页面直接返回到首页,支付成功页面需要隐藏导航栏,使用的是<UINavigationControllerDelegate>隐藏
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.delegate = self;
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
BOOL isSelfVC = [viewController isKindOfClass:[self class]];
[self.navigationController setNavigationBarHidden:isPageData animated:animated];
}
点击页面按钮返回到首页或者返回上一页使用方法
[self.navigationController popToRootViewControllerAnimated:YES];
[self.navigationController popToViewController:viewControler animated:YES];
执行后再到UINavigationControllerDelegate方法发现navigationController值为nil
WeWork Helper20191019110344.png
这样返回到指定页面后那个页面存在的导航栏会消失
解决办法:
在执行pop方法之前加上设置导航栏显示的代码
[self.navigationController setNavigationBarHidden:NO animated:NO];
网友评论