How to hide parent tabbar when pushing controller in navigationController
After spending hours and posting a question here I found that the solution to this problem is adding the following line after the instantiation of ArticleController.
articleController.hidesBottomBarWhenPushed = YES;
how to hide tab bar when push and show tab bar when back
Edit: That solved the problem.
It makes sense that the tab bar is appearing because when going clicking back from VC2 to VC3, nothing is telling VC3 to hide its Tab Bar.
I think you have 2 solutions here (but haven't tested any):
- You can try doing something like this guy did. He added the hidesBottomBarWhenPushed logic in BackButtonPressed Handler.
- In VC3, do
self.tabBarController?.tabBar.hidden = true
inViewDidLoad
orviewWillAppear
How to hide the tabBar when push a view?
use this methood in the UIViewController class where you want to hide the tabBarController
-(BOOL)hidesBottomBarWhenPushed
{
return YES;
}
Update
As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.
How do you hide/unhide the tab bar when pushing/popping
I actually figured it out. Basically in your viewdidAppear you add in self.hidesBottomBarWhenPushed = true and in your viewDidDisappear you add in
self.hidesBottomBarWhenPushed = false. Thanks for your guys's answers anyways.
hide / show tab bar when push / back. swift
As it's name suggest, hiddenBottomBarWhenPushed only hide bottom bar if needed, it will not unhide bottomBar.
You can do this to get it works:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.tabBar.hidden = true/false
}
or simply put self.tabBarController?.tabBar.hidden = true/false
in prepareForSegue
But I would not recommend you to do so, as it would be weird if bottomBar suddenly popped out, user will thought they suddenly back to rootViewController while they are not.
Users should always know where they are in your app and how to get to their next destination.
Hide TabBar when pushed into the navigation stack and bring it back when popped out of the navigation stack
Ok, So finally I got my answer, this is what I am suppose to do.
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:aViewController animated:YES];
self.hidesBottomBarWhenPushed=NO;
So basically hidesBottomBarWhenPushed = YES, and then push your view controller and then hidesBottomBarWhenPushed = NO; this works like a charm.
Thanks to eddy and his post here
Related Topics
Dispatch_Once_T' Is Unavailable in Swift: Use Lazily Initialized Globals Instead
Xcode Error: Missing Required Module 'Firebase'
Synchronize Properties in Swift 3 Using Gcd
In Swiftui How to Set the Environment Variable of Editmode in an Xcodepreview
Terminate Subprocesses of MACos Command Line Tool in Swift
How to Remove Multiple Items from a Swift Array
Making Nsdecimalnumber Codable
Perform a Segue Programmatically
Difference Between Switch Cases "@Unknown Default" and "Default" in Swift 5
Stop Objects from Colliding Using Spritekit
Stopping an Running Skaction - Sprite Kit
Handling Network Error in Combination with Binding to Tableview (Moya, Rxswift, Rxcocoa)