简体   繁体   English

用NavigationBar替换TabbarController中的一个ViewController

[英]Replace one ViewController in TabbarController with NavigationBar

I noticed in Whatsapp there are four tabs. 我注意到在Whatsapp中有四个选项卡。 If you disable the access to Contacts, the view in first tab, Favorites, will be replaced with the information view which will guide user to open the Settings. 如果您禁用对联系人的访问,则第一个选项卡中的“收藏夹”视图将被信息视图替换,该信息视图将指导用户打开“设置”。

I was trying to copy this function with following codes (in AppDelegate): 我试图使用以下代码(在AppDelegate中)复制此函数:

let gotoSettingsVC = UIApplication.sharedApplication().keyWindow?.rootViewController!.storyboard?.instantiateViewControllerWithIdentifier("gotoSettingsViewController") as! GotoSettingsViewController
let tabbarController = UIApplication.sharedApplication().keyWindow?.rootViewController! as! UITabBarController

gotoSettingsVC.tabBarItem = tabbarController.tabBar.selectedItem
tabbarController.viewControllers![tabbarController.selectedIndex] = gotoSettingsVC

The gotoSettingsVC can be shown correct but without Navigation Bar. 可以正确显示gotoSettingsVC,但没有导航栏。 How to show this View with a Navigation Bar like the normal View in tabbarController? 如何使用导航栏显示此视图,就像tabbarController中的普通视图一样?

thank you for any help. 感谢您的任何帮助。

GotoSettingsViewController嵌入导航控制器中,并将其设置为tabBar控制器视图控制器之一。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM