在我的UITabBarController中推送时,视图控制器隐藏了标签栏
注意:我试图在任何可能的地方将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吧!
我试图将属性hidesBottomBarWhenPushed设置为false到我能够的任何对象,但没有成功。
请帮帮我!!!
此致,Alx
看起来您已将tabBarController嵌入到NavigationController中。 这可能是在将新的ViewController压入堆栈时隐藏选项卡的原因。 而是将每个tabBarController的ViewControllers嵌入到他们自己的NavigationController中。
- 如何正确地将佛教日期转换为格里高利日期
- 使用UIPageViewController和UISegmentedControl进行平滑过渡,就像在Apple Music App中一样
- 如何在iOS中实现Blowfishalgorithm
- iOS:我可以从加速计数据中获得音高/偏转/滚动吗?
- 如何在iOS应用程序中使用客户端证书身份validation
- didRegisterForRemoteNotificationsWithDeviceToken不会在ios 9中调用
- 单点触摸 – QLPreviewController问题
- 保持选定的单元大量reloadRowsAtIndexPaths UITableView
- UITableViewCell展开和折叠