I'm having weird view controller issues when using the -hidesBottomBarWhenPushed
property. This is an iOS 7 only project. Using Xcode 5.whatever is latest. No betas.
There are several issues, but I think they are all surrounding the same issue. Here are my different use cases.
Both Use Cases start with the same layout. UITabBarController (2 tabs) --> UINavigationController (Tab1) --> Tab2 (not needed for example) --> set as rootViewController on my application window.
Use Case 1:
ViewController1 - Has navigation controller and tableview with content. Push a view controller that does not need the tab bar (uses toolbar with custom content).
ViewController2 - Tab bar is not showing, things look great so far. Now I need to push another view controller that needs the tab bar again.
ViewController3 - Tab bar is showing, things are still good to go. One more level to go, tab bar still needs to show.
ViewController4 - Tab bar is missing. Not good. This sucks, lets back up.
ViewController3 - Tab bar is now gone here too. View takes up full space, that is good, but no tab bar. Back we go.
ViewController2 - What the eff? My toolbar is shaded and can't be selected, and the view is sized like there is a tab bar there. I can scroll content and see where it thinks the view ends. This view is toast, back to home.
ViewController1 - Everything is back to normal. Tab bar showing no problem. I can drill back in with no issues going in, but coming back, everything is hosed pretty bad.
Use Case 2:
We can skip a view and get similar results.
ViewController1 - Same as Use Case 1. Our home view, where everything is working and looks great.
ViewController3 - Lets skip the toolbar view and keep our tab bar in place. No sweat. Tab bar shows up fine. Looks good, lets drill in one more level.
ViewController4 - The hell? Tab bar is here, but it looks shaded or selected. Content is offset up from the tab bar, it doesn't line up with the tab bar. About the same height as the tab bar. If we toggle tabs, the tab bar loses its shaded state. Come back to same screwed up view... looks fine now. The table view here is now nested perfectly on top of the tab bar. I give up!!
ViewController3 - The tab bar here looks fine at least. Whew! One less thing to fix.
ViewController1 - Home still looks good. Please don't ever leave me home view.
Those are the steps I take. Now for how I'm pushing these views.
ViewController1 - Does most of the heavy lifting. Due to examples and fixes from other questions, is setting the -hidesBottomBarWhenPushed property before pushing views out the door.
All View Controllers have a property set during init, self.hidesTabBar; YES hides it, NO shows it.
ViewController2 alloc/init; // normal init stuffs
// set current view property to the property on next views property (set in init of view)
[self setHidesBottomBarWhenPushed:ViewController2.hidesTabBar];
[self.navigationController pushViewController:ViewController2 animated:YES];
// set back after pushing to what the current view needs to be at
[self setHidesBottomBarWhenPushed:self.hidesTabBar];
This method continues for all views being pushed onto the nav stack. Basically, before I push, I set my current view -hidesBottomBarWhenPushed property to the same as the view I'm about to push. After I push, I set it back to what it was before I pushed.
I have tried every combination of setting this and I end up with problems all over. I need to be able to control when the tab bar gets shown. Some cases it will always be up. Some it will show/hide/show/show, and every combination in between. The only constant is that it will always be shown on the root/first view of the navigation stack. After that, it all depends on the path the user takes. Help!!!