hide tab bar in view with push

前端 未结 7 1687
离开以前
离开以前 2021-02-03 22:51

I have a tabBar + NavigationViewController. The Tab bar has collection view with cells(Say view1) and with cells a push seag

相关标签:
7条回答
  • 2021-02-03 23:01

    You have to work with viewWillAppear or viewDidAppear. viewDidLoad will be called when view1 is loading (showing) the first time. If you move from view1 to view2 and back the viewDidLoad won't be called again. Therefore you have to use viewWillAppear or viewDidAppear like

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        self.tabBarController?.tabBar.hidden = false
    }
    

    Put this code in your view1 controller. The viewWillAppear or viewDidAppear will be called every time navigating back to view1

    0 讨论(0)
  • 2021-02-03 23:06

    In the viewDidload set the UIViewController hidesBottomBarWhenPushed to yes:

    self.hidesBottomBarWhenPushed = YES;
    

    This way the UINavigationController takes care of hiding the tab bar.

    0 讨论(0)
  • 2021-02-03 23:12

    Bruno Fernandes's answer in Swift:

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "YourSegueIdentifier" {
            let destinationController = segue.destinationViewController as! YourViewController
            destinationController.hidesBottomBarWhenPushed = true
        }
    }
    

    This was the answer that worked for me. Putting hidesBottomBarWhenPushed in the viewDidLoad method didn't work.

    Thanks Bruno!

    0 讨论(0)
  • 2021-02-03 23:13

    Use in prepareForSegue:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
            RecipeDetailViewController *destViewController = segue.destinationViewController;
            destViewController.recipeName = [recipes objectAtIndex:indexPath.row];
    
            // Hide bottom tab bar in the detail view
            destViewController.hidesBottomBarWhenPushed = YES;
        }
    }
    
    0 讨论(0)
  • 2021-02-03 23:14

    if you want to hide TabBarController Bottom Bar : #Swift 3

    In YourViewController : in ViewDidLoad() method

    self.tabBarController?.tabBar.isHidden = false
    
    0 讨论(0)
  • 2021-02-03 23:15

    Make sure to check this option only on the ViewController whose tab bar you wish to be hidden.

    Thanks to iHarshil for the suggestion.

    0 讨论(0)
提交回复
热议问题