"ios14 popToRootViewControllerAnimated bottom tabbar disappears" problem solution

ios14 popToRootViewControllerAnimated bottom tabbar disappears problem handling

The solution is:
Override the following method in the UINavigationController class:

  -(NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated
   {

           if (animated) {
    
           UIViewController *popController = self.viewControllers.lastObject;
           popController.hidesBottomBarWhenPushed = NO;
          }
          return [super popToRootViewControllerAnimated:animated];
  }

Modify in the custom push method in basevc:

     - (void)dsPushViewController:(UIViewController*)vc animated:(BOOL)animated{

                   if (self.navigationController.viewControllers.count > 0) {
                    // 当前导航栏, 只有一个viewController push的时候设置隐藏
                  if (self.navigationController.viewControllers.count == 1) {
                  vc.hidesBottomBarWhenPushed = YES;
                  }
                  } else {
                 vc.hidesBottomBarWhenPushed = NO;
                 }

                [self.navigationController pushViewController:vc animated:animated];

     }

Guess you like

Origin blog.csdn.net/weixin_42050662/article/details/110821824