简体   繁体   English

UITabController,具有用于所有选项卡视图项的共享标题栏

[英]UITabController with shared title bar for all tab view items

When my app launches, I'll have an initial list that the user chooses from. 当我的应用启动时,我将有一个初始列表供用户选择。 Once chosen, the user should be taken to a UITabController that has content related to the item chosen on the initial list. 选择之后,应将用户带到UITabController,该UITabController的内容与初始列表中选择的项目有关。

For the user to get back to that list, I'd like to have a Title/Tool bar at the top of the app. 为了让用户回到该列表,我想在应用程序顶部具有标题/工具栏。 The bar should contain a title and a button that let's the user get back to that first modal list of items where a new item can be chosen. 该栏应包含一个标题和一个按钮,让用户返回到可以选择新项目的项目的第一模式列表。

I know I can have each individual view controller specify a title as well as a button, but I'd like it controlled at the AppDelegate rather than at each view so that each view doesn't have to contain duplicate logic to accomplish this. 我知道我可以让每个单独的视图控制器指定一个标题以及一个按钮,但是我希望它在AppDelegate而不是每个视图中进行控制,因此每个视图不必包含重复的逻辑即可完成此操作。

Ideally my app would be a UINavigationController with a UIViewController that contains a UITabViewController; 理想情况下,我的应用程序是一个UINavigationController,其中的UIViewController包含一个UITabViewController; however, it seems that Apple frowns on this type of flow. 但是,苹果似乎不喜欢这种类型的流程。

Is there a way to manage this? 有办法解决吗?

I don't think there's any way to do this at the tab bar controller level. 我认为没有任何方法可以在标签栏控制器级别执行此操作。 You could make a subclass of UIViewController to add some methods and properties to take care of your title bar, and then have each of your individual controllers inherit from that class instead of directly from UIViewController 您可以创建UIViewController的子类以添加一些方法和属性来处理标题栏,然后让每个单独的控制器从该类继承,而不是直接从UIViewController继承。

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

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