airsoftFreak
airsoftFreak

Reputation: 1608

How do I remove tab bar when user navigates to another screen?

My goal is simply to remove my app's tab bar whenever the user navigates to a specific screen, so that I have more space available.

Currently, my storyboard looks like this:

enter image description here

Whenever the user clicks a button they will be taken to another screen, which is the last screen in the sequence. My goal is to simply remove the tab bar, but keep the navigation.

If I use a show detail segue, then it will remove the tab bar but also the navigation, which is something I don't want.

This is the final screen (but it still has tab bar):

enter image description here

Upvotes: 3

Views: 2004

Answers (4)

Ketan Parmar
Ketan Parmar

Reputation: 27438

You can write prepareforsegue like below,

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender    {

segue.destinationViewController.hidesBottomBarWhenPushed = YES;

// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}

Swift:

   override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    segue.destinationViewController.hidesBottomBarWhenPushed = true

}

So in destination view controller tabbar will not shown.

According to your question you can implement in FirstTableViewcontroller and tabbar will not visible in TaretViewController.

Hope this will help :)

Upvotes: 1

Luca D'Alberti
Luca D'Alberti

Reputation: 4849

You can even set the property hidesBottomBarWhenPushed equal to true on your DestinationViewController. You can do it in your prepareForSegue method override.

if let vc = segue.destinationViewController as? YOURVIEWCONTROLLER {

    vc.hidesBottomBarWhenPushed = true
}

In this way, if the ViewController should need the bottom bar in other cases, it'll be shown

Upvotes: 4

Cjay
Cjay

Reputation: 1093

All you need it to set hidesBottomBarWhenPushed = true on the view controller you want it to be hidden on. insert in viewDidLoad()

You can also set this in the storyboard of the children view controllers

enter image description here

Upvotes: 6

Jagveer Singh
Jagveer Singh

Reputation: 2328

hide in viewWillDisappear

self.tabBarController.tabBar.hidden = YES;

Upvotes: 0

Related Questions