1

I have an app with an UITabBarController and UINavigationControllers as tabs. The bars are all set to be non-translucent. Which means the content area of the view controllers is just in between the bottom of the navigation bar and the top of the tab bar.

Now I would like to hide the UITabBar (on action). I guess for animating this requires a proper extended layout setup - but to start simple one would think this should do the trick without the animation:

if let tabBar = self.tabBarController?.tabBar {
    tabBar.hidden = !visible
}

While the UITabBar does hide, it only reveals free space behind. The content area of the view controllers does not get adjusted.

How can I force all view controllers inside the tab bar (and subsequently in the navigation controllers) to re-layout?

And why isn't this happening automatically?

tcurdt
  • 14,518
  • 10
  • 57
  • 72
  • It isn't happening automatically because the tab bar controller is not expecting you to do this. You can hack your way around it, however, and get the nav controller's view to occupy the whole screen. Stack Overflow has _many_ suggested hacks for doing this. Did you try searching? – matt Aug 21 '16 at 17:37
  • By the way, did you try setting your navigation controller's child's `hidesBottomBarWhenPushed` before pushing? – matt Aug 21 '16 at 17:40
  • @matt there are *many* UITabBar posts but most of them focus on different things (animating the hide or the mentioned extended layout) - hence I don't think it's a duplicate. Please show me a link to a similar question if you think otherwise. – tcurdt Aug 21 '16 at 17:48
  • I also don't see how `hidesBottomBarWhenPushed` is relevant as I am not pushing. – tcurdt Aug 21 '16 at 17:49
  • Okay, let me spell it out a little more. The navigation controller has a child view controller. It got pushed. The navigation controller is contained by a tab bar controller. `hidesBottomBarWhenPushed` will hide the tab bar of a containing tab bar controller. – matt Aug 21 '16 at 19:03
  • But if you are going to change horses in the middle of the stream by hiding the tab bar suddenly like this, the duplicate I marked is exactly relevant, as it shows you how to fix the blank space which is exactly what you are asking about. – matt Aug 21 '16 at 19:04
  • Would you say the root view controller of a navigation controller got pushed? I wouldn't. And right now there is only the root view controller. Hence I was wondering how the `hidesBottomBarWhenPushed` is relevant. Trying to be a bit more clear maybe - the UITabBarController is the root of all my navigation. – tcurdt Aug 21 '16 at 19:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/121485/discussion-between-tcurdt-and-matt). – tcurdt Aug 21 '16 at 19:25
  • Did you ever find a good answer to this? – Rob Jul 26 '18 at 21:32
  • @Rob IIRC I went a different route – tcurdt Jul 27 '18 at 09:27

0 Answers0