简体   繁体   English

如何设置NavigationController的根viewController

[英]How can i set root viewController of NavigationController

i am using TabBar in my application i want to set viewController on tab clicked. 我在应用程序中使用TabBar,我想在单击的选项卡上设置viewController。 My tabs rootviewcontroller is NavigationController.i want to change root viewController of that tab's navigation controller eachTime new on tab select. 我的选项卡rootviewcontroller是NavigationController。我想每次在选项卡选择上更改该选项卡的导航控制器的root viewController。

let nav = UINavigationController(rootViewController: homeViewController)
appdelegate.window!.rootViewController = nav

I think this is what you are looking for: 我认为这是您要寻找的:

let nav1 = UINavigationController(rootViewController: UIViewController())
let nav2 = UINavigationController(rootViewController: UIViewController())

let tab = UITabBarController()
tab.viewControllers = [nav1, nav2]

appdelegate.window!.rootViewController = tab

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何定义嵌入ViewController的NavigationController? - How can i define a NavigationController that embeds a ViewController? 如何将 NavigationController 嵌入到 xib 中的 Viewcontroller - How can I embed NavigationController to Viewcontroller in xib 如何在 Swift 中呈现 VC 并设置为新的 Root viewController? - How can I present VC and set as new Root viewController in Swift? 如何使用StoryBoard在NavigationController和ViewController之间传递值? - How can I pass value between NavigationController and ViewController with StoryBoard? 如何在导航控制器中从下到上呈现/关闭视图控制器? - How can i present/dismiss viewcontroller from bottom to top in navigationcontroller? 从navigationController解散后,如何跳过ViewController? - How can I skip a ViewController when dismissing from navigationController? 初始化新的NavigationController时如何在根ViewController中添加barbuttonitem - How to add a barbuttonitem to root viewcontroller when init a new navigationcontroller 如何从Xib加载的ViewController中设置NavigationController navigationItem标题 - How to set NavigationController navigationItem title from ViewController loaded by Xib 如何在将数据传递给 viewController 时实例化 navigationController? - How do I instantiate navigationController while passing data to viewController? 如何从一个navigationcontroller推送到多个viewcontroller? - How do I push from one navigationcontroller to multiple viewcontroller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM