简体   繁体   English

一个选项卡栏控制器中多个选项卡的一个导航控制器

[英]One navigation controller for multiple Tabs in a Tab Bar Controller

I am looking to have one Navigation Controller that will be atop multiple Tab Views in a Tab Bar Controller. 我正在寻找一个导航控制器,它将位于选项卡栏控制器中的多个选项卡视图的上方。

This Navigation Controller will have an Info button in the top right that will segue to the same view no matter what view the user is on (VC 1 / 2 / 3). 该导航控制器的右上角将有一个“信息”按钮,无论用户位于哪个视图(VC 1/2/3),该按钮都可以锁定到同一视图。

Here's what I have set up in storyboard so far: 到目前为止,这是我在情节提要中设置的内容:

需要在所有选项卡上访问红色导航栏。 The Problem: The red Nav bar is only accessible through "First VC." 问题:红色导航栏只能通过“第一个VC”访问。

What I need: I need the red Nav bar to be accessible through ALL the tab views. 我需要什么:我需要红色的导航栏可通过所有选项卡视图访问。 (First VC / VC 1 / VC 2 / VC 3). (第一个VC / VC 1 / VC 2 / VC 3)。

What I researched: I read that you can simply embed each tab view in a Navigation Controller. 我研究的内容:我读到您可以将每个选项卡视图简单地嵌入到Navigation Controller中。 The problem I foresee here is bad re-usability of the navigation bar. 我在这里预见的问题是导航栏的可重复使用性很差。 That red bar will need to be created 4 times, and each of those 4 buttons will have to link to the same view 4 times. 该红色条需要创建4次,并且这4个按钮中的每个按钮都必须链接到同一视图4次。

What is the best approach for having ONE navigation bar that is accessible through ALL the Tab Views. 通过所有选项卡视图访问一个导航栏的最佳方法是什么。

Thanks. 谢谢。

This has been resolved. 此问题已解决。 What I ended up doing was embedding EACH VC that has a Tab Bar Item in its own Navigation Controller (in my original post, these are Green VC 2 / Blue VC 3 / Tan VC 4). 我最终要做的是将具有选项卡栏项的EACH VC嵌入其自己的导航控制器中(在我的原始帖子中,这些是Green VC 2 / Blue VC 3 / Tan VC 4)。 As @JohnD pointed out in his comment, this gives me much more flexibility on customizing the Nav bar for each tab. 正如@JohnD在他的评论中指出的那样,这为我自定义每个选项卡的导航栏提供了更大的灵活性。

Regarding my Button concern: Each of the nav bars have a settings button. 关于我的按钮问题:每个导航栏都有一个设置按钮。 Instead of cluttering up the Main storyboard with multiple segues to the Settings VC, I created a new storyboard. 我创建了一个新的情节提要板,而不是用多个设置使“主要”情节提要板杂乱无章地设置到VC。 Within this storyboard, I have a Settings View Controller with all the functionality and options needed. 在此情节提要中,我具有一个设置视图控制器,其中包含所需的所有功能和选项。 The buttons instantiate this new VC with code, as seen in this post: How to push and present to UIViewController programmatically without segue in iOS Swift 3 这些按钮使用代码实例化了这个新的VC,如这篇文章所示: 如何在iOS Swift 3中以编程方式推送和呈现给UIViewController而不进行选择

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

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