Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How would I hide the tab bar in the bottom of tabbed application programmatically in swift?

I am building a tab based application, but I also have a login screen in which I want the tabs hidden.

Where do I start?

hi michael,

i ran into the same problem when i was trying to follow the ribbit tutorial using swift instead of objective-c. there's a lesson there teaching how to hide the tab bar in the bottom (but it's based on objective-c). anyway, after several trials, i was able to hide it in swift using the following code in the scene that leads to the scene with the tab bar i wanted to hide (not in the scene with the bar i wanted to hide) :

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showLogin"{
        println("showLogin seque called")
        let bottomBar = segue.destinationViewController as LoginViewController
        bottomBar.hidesBottomBarWhenPushed = true
        bottomBar.navigationItem.hidesBackButton = true
    }
}

Roderick Kar I appreciate the quick response. Would you be able to explain what is happening in this snippet? I'm guessing prepareForSegue is a built in function from the ViewController right? and it looks like you set the boolean values for its UI elements in this case the bottom tab through it, but for the rest I'm having trouble following

Also... how can I set the segue.identifer?

Thank you very much. I've wasted way too much time on this problem.

1 Answer

What if there will be a keyboard shown on the next screen. I have a tab bar shown in black when keyboard pops up :(