将单个导航控制器与选项卡栏控制器相结合



我想将导航控制器和选项卡栏控制器组合在一起,并通过选项卡栏显示3个视图控制器。

如果我将三个vcs中的每一个嵌入到它自己的导航控制器中,然后将它们添加到选项卡栏控制器中,我就可以实现这一点。然而,现在有三个导航控制器。

但根据苹果的文档,可以使用单个导航控制器:https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/CombiningViewControllers.html

To create a combined interface with three tabs that contain custom view controllers and one tab that contains a navigation controller:
1) Create three custom view controllers, one for each tab, and a navigation controller.
2) Select the three custom view controllers and the navigation controller (only the navigation controller scene, not it’s root view controller).
3) Choose Editor > Embed In > Tab Bar Controller.
4) Display the tab bar controller as the first view controller by selecting the option Is Initial View Controller in the Attributes inspector (or present the view controller in your user interface in another way.)

这句话中的第一句话提到"导航控制器",即单数。在指令中,它说"导航控制器",也是单数。

但是,当我按照这些说明进行操作时,我会得到一个选项卡栏,其中包含4个项目,其中3个用于视图控制器,一个用于导航控制器。

如果可以像苹果文档中所说的那样拥有一个导航控制器,那么苹果的说明有什么问题?如何在选项卡栏中获取三个项目?

苹果文档只是说,您可以在单个选项卡中使用导航控制器来控制该选项卡中的导航。如果您有多个选项卡,并且希望所有选项卡中都有导航控制器,那么是的,您可以这样做,但这三个导航控制器是独立的。

换句话说,你可以在应用程序中同时使用选项卡栏和导航控制器,但目的不同。选项卡栏提供顶级导航,导航控制器提供向下导航。您不能同时使用选项卡栏和导航控制器来控制顶级导航。

以下是关于导航的苹果人机界面指南。

最新更新