简体   繁体   English

如何将UITabBarController子视图添加到UINavigationController

[英]How do I add UITabBarController subview to UINavigationController

I am new to Objective-C and Cocoa and I am trying my way through some tutorials with some success. 我是Objective-C和Cocoa的新手,我正在尝试一些成功的教程。 One task is troubling me. 一项任务困扰着我。 I am trying to create a root view controller that is a navigation controller as given by this tutorial: 我正在尝试创建一个根视图控制器,它是本教程给出的导航控制器:

http://fuelyourcoding.com/iphone-view-switching-tutorial/ http://fuelyourcoding.com/iphone-view-switching-tutorial/

On the second page that is pushed I would like the option to load a subview that is a TabBarController. 在要推送的第二页上,我希望选择加载作为TabBarController的子视图。 Is this within iOS view guidelines. 这是否在iOS视图准则中。 Is this possible? 这可能吗? If so, could someone give some code snippets and explain necessary instantiations and connections in IB? 如果是这样,有人可以提供一些代码片段并解释IB中的必要实例化和连接吗? Your help is appreciated in advance! 预先感谢您的帮助!

No, you should not push a UITabBarController to a UINavigationController stack. 不,您不应该将UITabBarController推送到UINavigationController堆栈。

Perhaps tell us what you're trying to accomplish and someone can suggest an alternative. 也许告诉我们您要达到的目标,然后有人可以提出替代方案。

From Apple's View Controller Programming Guide - Tab Bar Controllers: 从Apple的《 View Controller编程指南-标签栏控制器:

Note: Although a navigation controller can be embedded inside a tab, the reverse is not true. 注意:尽管导航控制器可以嵌入在选项卡中,但事实并非如此。 Presenting a tab bar interface from within a navigation interface is potentially confusing for users. 从导航界面中显示选项卡栏界面可能会使用户感到困惑。 A navigation interface uses one or more custom view controllers to present an interface focused on one goal, which is usually the management of a specific type of data. 导航界面使用一个或多个自定义视图控制器来呈现针对一个目标的界面,该目标通常是对特定类型数据的管理。 By contrast, the tabs of a tab bar interface can reflect completely different purposes in an application and need not be related in any way. 相比之下,选项卡栏界面的选项卡可以反映应用程序中完全不同的目的,并且无需以任何方式关联。 In addition, pushing a tab bar controller on a navigation stack would cause the tabs to be displayed for that screen only and not for any others. 另外,在导航堆栈上推动选项卡栏控制器将导致仅针对该屏幕显示选项卡,而不针对其他任何屏幕显示选项卡。

I cannot answer your question directly, but in my app I have a UITabBarController which displays multiple UINavigationControllers and other types of controllers. 我无法直接回答您的问题,但是在我的应用程序中,我有一个UITabBarController,它显示多个UINavigationControllers和其他类型的控制器。 So I think you may have it the wrong way around. 因此,我认为您的做法可能有误。 In other words, create a project which uses a UITabbarController as the base controller and when you select a tab, load up the corresponding UINavigationController (or other type of controller) as necessary. 换句话说,创建一个使用UITabbarController作为基本控制器的项目,并在选择选项卡时根据需要加载相应的UINavigationController(或其他类型的控制器)。

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

相关问题 如何将UItabBarController添加为子视图 - how to add UItabBarController as a subview 如何在AppDelegate中以编程方式添加UITabBarController和UINavigationController? - How to programmatically add a UITabBarController & UINavigationController in AppDelegate? 将子视图添加到UITabBarController - Add a subview to a UITabBarController 将UINavigationController添加到iPhone上的子视图 - Add UINavigationController to subview on iPhone 当“以编程方式”创建UINavigationController和UITabBarController时,如何解决它们的功能(如viewWillAppear?) - When “programmatically” creating UINavigationController and UITabBarController, how do I address their functions (like viewWillAppear?) 如何在使用UINavigationController进行转换时向UIWindow添加子视图并防止其消失? - How do you add a subview to UIWindow and prevent it from disappearing when transitioning using UINavigationController? 如何将UICollectionView作为子视图添加到UIView? - How do I add a UICollectionView to a UIView as a subview? 如何在Theos中向UIStatusBar添加子视图? - How do I add a subview to UIStatusBar in Theos? 如何向视图添加子视图 - How do I add a subview to a view 从AppDelegate将UIBarButtonItem添加到UITabBarController中包含的UINavigationController - Add UIBarButtonItem to UINavigationController contained in a UITabBarController from AppDelegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM