使用Tab栏项目将StoryBoard添加到现有的UINavigation中

时间:2013-03-07 00:27:26

标签: ios xcode

我有一个带有标签栏的UI导航项目,每个标签栏都包含XIB和ViewController,项目通过此方法从App委托加载每个ViewController:

MyFourthView *fourthViewController;
 fourthViewController = [[MyFourthView alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc]
                             initWithRootViewController:fourthViewController];
[localControllersArray addObject:localNavigationController];

现在我正在尝试将storyboard添加到我的项目中,并以编程方式从app delegate加载它作为第五个标签栏视图,但我不知道我该怎么做?因为故事板中没有XiB所以上面的方法不起作用?

2 个答案:

答案 0 :(得分:2)

如果您要添加到标签栏的第五个导航控制器是故事板中的根/初始视图控制器,您可以像这样实例化它:

UINavigationController *fifthNavigationController = [[UIStoryboard storyboardWithName:@"yourstoryboardname" bundle:nil] instantiateInitialViewController];

如果不是,请给它一个故事板ID并将其实例化为:

UINavigationController *fifthNavigationController = [[UIStoryboard storyboardWithName:@"yourstoryboardname" bundle:nil] instantiateViewControllerWithIdentifier:@"storyboardIdOfYourNavController"];

答案 1 :(得分:0)