简体   繁体   English

如何将视图控制器更改为选项卡栏控制器作为根视图控制器

[英]How to change view controller to tab bar controller as root view controller

I set the simple view controller as root view controller through navigation controller. 我通过导航控制器将简单视图控制器设置为根视图控制器。 Now I want to set the tab bar controller as root view controller. 现在,我想将标签栏控制器设置为根视图控制器。 I am using Objective-C with Xcode 7. 我在Xcode 7中使用Objective-C。

Assuming you're inside a view controller when you want to switch, you could use: 假设要切换时位于视图控制器内部,可以使用:

UIStoryboard *sb = [self storyboard];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"tabBarController"];
self.view.window.rootViewController = vc;

Otherwise, you could call your app delegate and have it switch using its window property. 否则,您可以调用您的应用程序委托,并使用其window属性对其进行切换。

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

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