iOS开发 在ios14系统 使用 popToRootViewControllerAnimated:YES 时底部tabbar会被隐藏

之前在导航控制器的基类中push隐藏tabbar的写法:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    } else {
        viewController.hidesBottomBarWhenPushed = NO;
    }
    [super pushViewController:viewController animated:animated];
}

改成如下:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        // 当前导航栏, 只有一个viewController push的时候设置隐藏
        if (self.viewControllers.count == 1) {
            viewController.hidesBottomBarWhenPushed = YES;
        }
    } else {
        viewController.hidesBottomBarWhenPushed = NO; 
    }
    [super pushViewController:viewController animated:animated];
    }

这样就行了。

你可能感兴趣的:(iOS开发 在ios14系统 使用 popToRootViewControllerAnimated:YES 时底部tabbar会被隐藏)