Reputation: 267
Note: And I tried to set the hidesBottomBarWhenPushed to false everywhere it was possible...
Here is how I initialize my UITabBarController in my AppDelegate file:
func initTabBarController()
{
let myVC1 = MapVC()
let myVC2 = MapVC()
let myVC3 = MapVC()
let myVC4 = MapVC()
let controllers = [myVC1,myVC2,myVC3,myVC4]
self.myTabBarController = UITabBarController()
self.myTabBarController.viewControllers = controllers
myVC1.tabBarItem = UITabBarItem(
title: "Map",
image: image1,
selectedImage: image11)
myVC2.tabBarItem = UITabBarItem(
title: "Map",
image: image2,
selectedImage: image21)
myVC3.tabBarItem = UITabBarItem(
title: "Map",
image: image3,
selectedImage: image31)
myVC4.tabBarItem = UITabBarItem(
title: "Menu",
image: image4,
selectedImage: image41)
self.tabNavigationController = UINavigationController(rootViewController: self.myTabBarController)
self.tabNavigationController.navigationBar.translucent = false
}
Now Here is how I set the rootViewController of my main window:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.initTabBarController()
appDelegate.window!.rootViewController =
appDelegate.tabNavigationController
appDelegate.window!.makeKeyAndVisible()
And here is finally how I try to push a new view controller inside one of my ViewController (MapVC):
let v = UIViewController()
v.view.backgroundColor = UIColor.yellowColor()
self.tabBarController?.navigationController?.pushViewController(v, animated: true)
When this code is executed, the Yellow view is well displayed, but the bottom tab bar is hidden.
And I'd like to still have my Tab Bar!!!
I tried to set the property hidesBottomBarWhenPushed to false to any object I can, unsuccessfully.
Please help me!!!
Regards, Alx
Upvotes: 1
Views: 605
Reputation: 1370
It looks like you have embedded your tabBarController in a NavigationController. That is probably why the tabs are hidden when a new ViewController is pushed on the stack. Instead embed each of the tabBarController's ViewControllers inside their own NavigationController.
Upvotes: 2