注意:我试图在任何可能的地方将hidesBottomBarWhenPushed设置为false ...
以下是我在AppDelegate文件中初始化UITabBarController的方法:
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
}
现在我将如何设置主窗口的rootViewController:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.initTabBarController()
appDelegate.window!.rootViewController =
appDelegate.tabNavigationController
appDelegate.window!.makeKeyAndVisible()
最后我将尝试在我的一个ViewController(MapVC)中推送一个新的视图控制器:
let v = UIViewController()
v.view.backgroundColor = UIColor.yellowColor()
self.tabBarController?.navigationController?.pushViewController(v, animated: true)
执行此代码时,黄色视图会很好地显示,但底部的标签栏会被隐藏。
我还想拥有我的Tab Bar !!!
我尝试将属性hidesBottomBarWhenPushed设置为false,以便我可以使用任何对象。
请帮帮我!!!
此致 ALX
答案 0 :(得分:2)
看起来您已将tabBarController嵌入到NavigationController中。这可能是在将新的ViewController压入堆栈时隐藏选项卡的原因。而是将每个tabBarController的ViewControllers嵌入到他们自己的NavigationController中。