0
点赞
收藏
分享

微信扫一扫

UINavigationController官方文档学习

金牛豆豆 2022-03-11 阅读 85
ios

概述
A navigation controller is a container view controller that manages one or more child view controllers in a navigation interface. In this type of interface, only one child view controller is visible at a time. Selecting an item in the view controller pushes a new view controller onscreen using an animation, thereby hiding the previous view controller. Tapping the back button in the navigation bar at the top of the interface removes the top view controller, thereby revealing the view controller underneath.
导航控制器是管理导航界面中的一个或多个子视图控制器的容器视图控制器。在这种类型的界面中,一次只能看到一个子视图控制器。在视图控制器中选择一项使用动画在屏幕上推送新的视图控制器,从而隐藏以前的视图控制器。轻按界面顶部导航栏中的 “后退” 按钮可移除顶视图控制器,从而显示下方的视图控制器。
Use a navigation interface to mimic the organization of hierarchical data managed by your app. At each level of the hierarchy, you provide an appropriate screen (managed by a custom view controller) to display the content at that level. Figure 1 shows an example of the navigation interface presented by the Settings application in iOS Simulator. The first screen presents the user with the list of applications that contain preferences. Selecting an application reveals individual settings and groups of settings for that application. Selecting a group yields more settings and so on. For all but the root view, the navigation controller provides a back button to allow the user to move back up the hierarchy.
使用导航界面模仿应用程序管理的分层数据的组织。在层次结构的每个级别,您都提供适当的屏幕 (由自定义视图控制器管理) 以显示该级别的内容。下图显示了iOS模拟器中设置应用程序提供的导航界面的示例。第一个屏幕向用户显示包含首选项的应用程序列表。选择应用程序会显示该应用程序的各个设置和设置组。选择一个组会产生更多设置,依此类推。对于除根视图之外的所有视图,导航控制器提供了一个后退按钮,允许用户向上移动层次结构。
在这里插入图片描述
A navigation controller object manages its child view controllers using an ordered array, known as the navigation stack. The first view controller in the array is the root view controller and represents the bottom of the stack. The last view controller in the array is the topmost item on the stack, and represents the view controller currently being displayed. You add and remove view controllers from the stack using segues or using the methods of this class. The user can also remove the topmost view controller using the back button in the navigation bar or using a left-edge swipe gesture.
导航控制器对象使用有序数组管理其子视图控制器,称为导航堆栈。数组中的第一个视图控制器是根视图控制器,表示堆栈的底部。数组中的最后一个视图控制器是堆栈中最顶层的项目,代表当前显示的视图控制器。您可以使用segues或此类的方法从堆栈中添加和删除视图控制器。用户还可以使用导航栏中的 “后退” 按钮或使用左边缘滑动手势来移除最顶层的视图控制器。
The navigation controller manages the navigation bar at the top of the interface and an optional toolbar at the bottom of the interface. The navigation bar is always present and is managed by the navigation controller itself, which updates the navigation bar using the content provided by its child view controllers. When the toolbarHidden property is NO, the navigation controller similarly updates the toolbar with contents provided by the topmost view controller.
导航控制器管理界面顶部的导航栏和界面底部的可选工具栏。导航栏始终存在,并由导航控制器本身管理,导航控制器使用其子视图控制器提供的内容更新导航栏。当toolbarHidden属性是NO,导航控制器同样使用最顶层视图控制器提供的内容更新工具栏。(在子视图控制器更新导航栏和工具栏)
A navigation controller coordinates its behavior with its delegate object. The delegate object can override the pushing or popping of view controllers, provide custom animation transitions, and specify the preferred orientation for the navigation interface. The delegate object you provide must conform to the UINavigationControllerDelegate protocol.
导航控制器可以与委托对象配合使用。委托对象可以覆盖视图控制器的按下或弹出,提供自定义动画过渡,并指定导航界面的首选方向。您提供的委托对象必须符合UINavigationControllerDelegate协议。下图显示了导航控制器与其管理的对象之间的关系。使用导航控制器的指定属性访问这些对象。
在这里插入图片描述
A navigation controller is a container view controller—that is, it embeds the content of other view controllers inside of itself. You access a navigation controller’s view from its view property. This view incorporates the navigation bar, an optional toolbar, and the content view corresponding to the topmost view controller. Figure 3 shows how these views are assembled to present the overall navigation interface. (In this figure, the navigation interface is further embedded inside a tab bar interface.) Although the content of the navigation bar and toolbar views changes, the views themselves do not. The only view that actually changes is the custom content view provided by the topmost view controller on the navigation stack.
导航控制器是一个容器视图控制器 – 也就是说,它将其他视图控制器的内容嵌入其内部。你可以从导航控制器的视图中访问它的视图属性。此视图包含导航栏、可选工具栏和与最顶层视图控制器相对应的内容视图。下图显示了如何将这些视图组合起来以呈现整个导航界面。(在此图中,导航界面进一步嵌入到选项卡栏界面中。)尽管导航栏和工具栏视图的内容发生了变化,但视图本身却没有。唯一实际更改的视图是导航堆栈上最顶层视图控制器提供的自定义内容视图。
在这里插入图片描述

举报

相关推荐

0 条评论