简体   繁体   English

将IOS选项卡式导航栏制动到多个情节提要中

[英]Brake IOS tabbed bar navigation into several storyboards

I am developing an IOS app using a tabbed view controller as root controller. 我正在开发使用选项卡式视图控制器作为根控制器的IOS应用。 Basically the tabbed bar manages the presentation of the different app modules. 基本上,选项卡式栏管理不同应用程序模块的显示。 I would like to brake down my storyboard into several storyboards one for each tab so to brake it down in size and begin more manageable. 我想将我的情节提要分解成几个情节提要,每个选项卡一个,以便缩减其大小并开始更易于管理。

I cannot find any tutorial or suggestion on how to achieve that. 我找不到有关如何实现该目标的任何教程或建议。

You can create xib files via Xcode and create your view controllers with those. 您可以通过Xcode创建xib文件,并使用这些文件创建视图控制器。 You still have to reference and lay out your custom classes in the storyboard file, but you can manage all the details in the separate xib files. 您仍然必须在情节提要文件中引用并布局自定义类,但是您可以在单独的xib文件中管理所有详细信息。

I found a way. 我找到了一个方法。 I have created only the first tab via storyboard and then added new storyboard and tabs when the first controller is created. 我仅通过情节提要创建了第一个选项卡,然后在创建第一个控制器时添加了新的情节提要和选项卡。

In viewDidLoad: 在viewDidLoad中:

NSMutableArray *tabs = (NSMutableArray *)[self.tabBarController viewControllers];

[tabs addObjectsFromArray:[[NSArray alloc] initWithObjects:tab1, tab2, tab3, nil]];
[self.tabBarController setViewControllers:tabs];

Any tab is generated like this: 任何选项卡都是这样生成的:

UIStoryboard *board = [UIStoryboard storyboardWithName:@"FeedbacksStoryboard" bundle:nil];
UIViewController *controller = [board instantiateInitialViewController];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Feedback" image:nil tag:0];
controller.tabBarItem = theItem;

This was a good compromise. 这是一个很好的折衷。 I can now load different storyboard and my app looks modular even in interface builder 我现在可以加载不同的情节提要,即使在界面生成器中,我的应用程序也看起来模块化

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

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