I have a UITabBarController
where the default view controller is a UINavigationController
. I want to be able to hide the UITabBar of the UITabBarController when I push a certain view in the UINavigationController
.
I've tried adding:
delegate.tabBarController.hidesBottomBarWhenPushed = YES;
in my UINavigationController
before I push the view, but that doesn't seem to do the trick.
Any tips on what I should be doing or if it's even possible? Thanks in advance!
in the first UIViewController "FirstItemViewController"
in the next UIViewController "ExampleViewController"`
Look at this answer https://stackoverflow.com/a/36148064/3078925
I've figure out how to get this solved, I was running into the same issue, but Apple also tells us how to do it in the sample called: "The Elements" (http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html)
See function below on how to do it, add this to the init function of the view you want to push in!
It will automatically hide the tabbar like the photo app does on your iphone. And when you navigate back the parent view will just show the tabbar again.
Good luck
when working with storyboard its easy to setup view controller which will hide the tabbar on push, on the destination view controller just select this checkbox:
I'll let here my solution for this:
Calls the 'setHidden' method where you need it! I using this and the 'Singleton Pattern', then my subviews can hide the UITabBar in his Superview
This is better:
You have to set hidesBottomBarWhenPushed = YES on the controller you are going to push into the view...
I have tried most of the suggested solutions. In the end none of them worked for me.
hideTabBarWhenPushed hides the tab bar not only for the view controller that is pushed next but for all view controllers that are pushed within. For those I did want the tab bar controller to re-appear.
Orafaelreis' solution (see above) seemed to suite that most. But his attempt only worked for strict portrait orientations, not even for upside down. So I had to mend it. This is what I finally got:
The in-line comments should explain the reasoning for each statement. Though, there may be smarter ways of coding it.
There is one side effect in conjunction with hiding the status bar and navigation bar too, which I do not want to hide from you guys. 1. When returning from this navigation controller to the calling navigation controller then the status bar and navigation bar on the calling controller overlap until the device is rotated once or until the related tab has been choosen again after another tab came to front. 2. When the calling view controller is a table view and when the device is in landscape mode when returning to the table, then the table is displayed in the appropriate orientation for landscape but it is layed out as if it were portrait. The upper left corner is fine but some table cells plus tab bar are hidden beneath the screen. On the right hand side there is some free space. This, too, is fixed by rotating the device again.
I will keep you updated once I found solutions for these minor but nasty bugs.