简体   繁体   English

在没有Segue的情况下实例化标签栏控制器

[英]Instantiate Tab bar Controller without Segue

In all other instances I'm using a segue to transition to a tab bar controller, but I have a need now to load up a tab bar controller without a segue. 在所有其他情况下,我都在使用segue过渡到选项卡栏控制器,但是现在我需要在没有segue的情况下加载选项卡栏控制器。 To do this with a regular view I would use this: 为此,我将使用以下常规视图:

EditProfileView *view = [[self storyboard] instantiateViewControllerWithIdentifier:@"editProfileView"];
[self.navigationController pushViewController:view animated:YES];

The EditProfileView is one of the tabs on my tab controller. EditProfileView是我的选项卡控制器上的选项卡之一。 How do I change this so that it loads all the tabs? 如何更改此设置以使其加载所有选项卡?

You should push the UITabBarController instead. 您应该改为推送UITabBarController。 eg 例如

UITabBarController *tc = [[self storyboard] instantiateViewControllerWithIdentifier:@"tabbarcontroller"];
[self.navigationController pushViewController:tc animated:YES];

Make sure the tabbarcontroller's storyboard ID is the same 确保tabbarcontroller的情节提要ID相同

Also, if you want to present one particular viewcontroller: 另外,如果您想展示一个特定的视图控制器:

[tc setSelectedViewController:[tc.viewControllers objectAtIndex:0]];

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

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