简体   繁体   English

具有多个故事板的UITabBarController

[英]UITabBarController with multiple storyboards

I am developing an iOS app with Xcode 8 and Swift 3. 我正在使用Xcode 8和Swift 3开发iOS应用程序。

I have a Tab Bar Controller with one tab view embedded into a Navigation Controller , as you see below: 我有一个标签栏控制器 ,其中一个标签视图嵌入到导航控制器中 ,如下所示:

标签栏控制器,带有一个标签视图

As the project continues, the storyboard is getting bigger. 随着项目的继续,故事板越来越大。 I really don't like it. 我真的不喜欢它。 So, I would like to divide it into multiple storyboards. 所以,我想把它分成多个故事板。

My question is: 我的问题是:

How to divide a Tab Bar Controller & the associated tab's view controllers into multiple storyboards? 如何将标签栏控制器和相关标签的视图控制器分成多个故事板? What is the best practice to do it? 这样做的最佳做法是什么? And how to do it? 怎么做?

If your target is iOS 9 and above , you should create storyboard references for the view controllers you want to include in another storyboard. 如果您的目标是iOS 9及更高版本 ,则应为要包含在另一个故事板中的视图控制器创建故事板引用 Here's how it works: 以下是它的工作原理:

  1. Create a second storyboard, move the desired view controller into it and give it a Storyboard ID under the Identity inspector . 创建第二个故事板,将所需的视图控制器移入其中,并在Identity检查器下为其提供Storyboard ID

身份检查员

  1. Go to your first storyboard and search for Storyboard Reference in the Object library. 转到第一个故事板并在对象库中搜索Storyboard Reference

对象库 - 故事板参考

  1. Drag it into your storyboard and create a "view controllers" relationship with the tab bar controller just like you would with a view controller. 将其拖入故事板并与标签栏控制器建立“视图控制器”关系 ,就像使用视图控制器一样。

标签栏控制器与故事板中的视图控制器

  1. Under the Storyboard Reference's Attribute inspector , change your settings accordingly. Storyboard Reference的属性检查器下 ,相应地更改您的设置。 For Referenced ID , use the view controller's ID on the second view controller. 对于Referenced ID ,请在第二个视图控制器上使用视图控制器的ID

Storyboard参考的属性检查器

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

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