I read several answers to this question but couldn't figure out how to do it. I'm using Xcode 4.2 with ARC and no storyboards.
I'm developing an app based on the TabBar application template and extended it to contain 4 UITabBars
. I'm not using UINavigationController
but instead using UINavigationBar
next to the status bar. When the app is loaded with the first tab shown, I have a button on the UINavigationBar
and when I press it, I want to hide the UITabBar
and instead show the UIToolBar
at the same location where the UITabBar
was located.
I tried to hide and show using the hidden property (hiding the UITabBar
and showing UIToolBar
). What happens is the UITabBar
is hidden but the UIToolBar
is shown above the location where the UITabBar
was shown before. This looks ugly and I want it to be shown at the very bottom of the screen.
I think I can't use hidesBottomBarWhenPushed
as I don't use a UINavigationController
but instead using Navigation bar directly.
Also, I want to revert back to showing the UITabBar
and hide the UIToolBar
when pressing the same button on the UINavigationBar
.
I am not sure if my idea would work for your scenario. Here it is...
but before, just let me tell you that hiding UITabBar
, unlike hiding UINavigationBar
is not animated. So to me, hiding tabBar is not a user-friendly approach, unless you create your own subclass of UITabBarController
that animates hiding the UITabBar
.
You can use presentModalViewController:animated
and dismissModalViewControllerAnimated:
methods. The viewController that is being shown modally can have a UINavigationBar
, it pops out from the bottom of the screen and covers the UITabBar
with animation.
Hope that helps.