提供不同故事板文件的

提供不同故事板文件的

本文介绍了为 TabBar 的每个 ViewController 提供不同故事板文件的 UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在开发一个具有 UITabBarController 的应用程序.我们正在使用 Storyboard 来开发界面和流程.

My team is developing an application that has a UITabBarController. We are using Storyboard to develop the interfaces and the flows.

由于我们是一个团队,我们不能将所有流程都放在一个故事板中,因为这会导致与 SVN 同步的问题.因此,解决方案是将每个标签的流程放在一个不同的故事板文件.

Since we are a team, we cannot put all flow in just one storyboard, because it will cause in problems with syncing with SVN. So, the solution is to put each tab`s flow in one different storyboard file.

当我可以创建一个对象来进行连接(例如一个按钮)时,故事板之间的连接不是问题,正如我们在 本教程.

The connection between storyboards is not the problem when I can create an object to do the connection (a button, for example) as we can see in this tutorial.

但是当我将一个 UITabBarController 放在一个故事板中时,我无法以编程方式设置将为 tabBar 的每个按钮显示的故事板来管理底部栏(tabBar 本身)的视图元素.

But when I put a UITabBarController in one storyboard, I cannot manage the view element of the bottom bar (the tabBar itself) in a way to programmatically set the storyboard that will be displayed for each button of the tabBar.

现在,我们可以看到 TabBar 和 UIViewControllers 在同一个 .storyboard 文件中:

For now, I have the TabBar and the UIViewControllers in the same .storyboard file as we can see:

所以我需要的是通过一个 UITabBarController 连接不同的故事板.如何做到这一点?

So what I need is to connect different storyboards through one UITabBarController. How to do that?

推荐答案

你有点错过了故事板的重点,它让你看到应用程序的结构和视图控制器之间的关系.

You're kind of missing out on the point of storyboards, which is to let you see the structure of the app and relationships between view controllers.

听起来您对标签栏控制器使用情节提要并没有获得很多好处,因此以编程方式设置它可能是有意义的,这使您可以使用单独的情节提要自己实例化每个视图控制器.

It sounds like you're not getting a lot of benefit from using a storyboard for the tab bar controller, so it might make sense to set that up programmatically, which lets you instantiate each of the view controllers yourself using separate storyboards.

或者,您可以将标签栏控制器、任何必要的导航控制器以及每个导航控制器的根控制器包含在一个故事板中,然后让每个根控制器从其他故事板加载后续的视图控制器.

Alternatively, you could include the tab bar controller, any necessary navigation controllers, and the root controller for each nav controller in one storyboard, and then have each of those root controllers load subsequent view controllers from other storyboards.

这篇关于为 TabBar 的每个 ViewController 提供不同故事板文件的 UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:19