How to hide tabbar in Navigation Flow?
self.tabbarController.tabbar.hidden = true
This is not working. I called this from ViewWillAppear method.
Just check the Hide Bottom Bar on Push for your ViewController if you're using storyboard
Related
I have a tabbar controller with 3 tabs, each tab has navigation controller, on root view controller of each navigation controller i want tabbar and on other view controller in same navigation controller i dont want tabbar.
Any solution?
set self.tabBarController?.tabBar.isHidden = true in viewWillAppear method of your controller when you don't want tabbar
override func viewWillAppear(_ animated: Bool) {
self.tabBarController?.tabBar.isHidden = true
}
Setting alpha value 0 to tab Bar hides all items and including tab bar
You should set the tabbar alpha to 0. This will hide the UITabBar.
However you need to set isUserInteractionEnabled to false since even when its hided, the buttons are there & clickable still!
Hope this helps!
Set Transculent property of Tab bar to true or check the same from storyboard
Set hidesTabbarWhen Pushed property of Tab bar to true or check the same from storyboard
Set Tab bar hidden true on view controller where you want Tab bar and set Tab bar hidden to false on view controller where you don't want Tab bar
In my application, I hide tabbar by setting hidesBottomBarWhenPushed property of UIViewController. I'm not sure this behavior is designed or not, when I called popToRootViewController to pop all view controller stack, tabbar did not show properly if I pushed same view controller after. Even I tried to show tabbar by setting isHidden property after I called popToRootViewController but it didn't work neither. Weird part is, after tabbar disappeared, I pushed same view controller and I could see the tabbar when I tried to pop the view controller (not popToRootViewController) by using gesture to pop (swipe to pop). Though it disappeared when transition was completed.
FYI, this is step by step to produce this behavior.
init tabbar and navigation controllers on two tabs.
push view controller (hidesBottomBarWhenPushed is true) on one tab's navigation controller
pop all view controller from the navigation controller by calling popToRootViewController
4 change tab index by setting selectedIndex on tabbarController
push the same view controller
How does hidesBottomBarWhenPushed property work in detail to show/hide tabbar?
I'll talk about the problem in my app.
For every pages, I'll edit the self.navigationController?.navigationBar.isHidden and self.tabBarController?.tabBar.isHidden = false to guarantee the state of tabBar and navigationBar in the viewWillAppear.
Sample
// In this viewController, I'll show the navigation bar and hide tab bar
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = false
self.tabBarController?.tabBar.isHidden = true
}
The navigationBar and tabBar can keep their state from last view controller when you push a new one or pop a old one. So it will let we set in every view controller to control and ensure its state as I wish.
I have one app to play video that build with swift. I play video on view AVPlayerViewController by story board. and inside the AVPlayViewController are contain with tab bar and navigation bar that I use on previous screen. during play the Video, when I push the done on the top left it will return to the first before navigation bar. and I want to remove the navigation bar and tab bar also from my AVPLayerViewController. is it possible to remove its? and during play the video, when push done, it will return to previous screen that I want, not go to first screen of app. Everyone, have any idea with this?.
Thank you.
Hide Navigation And Tab bar in PlayViewController viewDidLoad method.
func viewDidLoad() {
self.navigationController.navigationBar.hidden = true
self.tabBarController.tabBar.hidden = true
}
Show it in viewWillDisappear method:
func viewWillDisappear(){
self.navigationController.navigationBar.hidden = false
self.tabBarController.tabBar.hidden = false
}
When I dismiss viewcontroller Navigation bar overlaps with status bar how to solve this issue ?
self.navigationController?.navigationBarHidden = true
add this code in your first view Controller
my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo.
the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:
[self.navigationController.tabBarController.tabBar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?
That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use
self.hidesBottomBarWhenPushed = YES;
In your init method or awakeFromNib... and then
[self.navigationController setToolbarHidden:NO animated:YES];
In the viewDidLoad for example.
That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.
Try to assigning toolbar with appropriate frame and adding it to self.tabBarController.view