zoukankan      html  css  js  c++  java
  • UINavigationController

    这从一些关于导航器的重要信息的官方文档文章摘编都翻译。便于参考。

    The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. 

    UINavigationController类为管理具有一定层次结构的内容实现了专门的视图控制器。

    A navigation controller object manages the currently displayed screens using the navigation stack, which is represented by an array of view controllers. The first view controller in the array corresponds to the root view controller. The last view controller in the array represents the view controller currently being displayed. 

    导航控制器对象使用导航栈管理当前屏幕显示的内容。它通过一个视图控制器数组来展现这些内容。数组中的第一个视图控制器相应导航控制器的根视图控制器。

    数组的最后一个视图控制器表示当前显示的视图控制器。


    Typically, you add a view controller to the top of the stack using the pushViewController:animated: method.Pushing a view controller displays its view in the navigation interface and updates the navigation controls accordingly. 

    通常。加入一个视图控制器到栈顶使用:pushViewController:animated: 方法。当push一个视图控制器时,视图控制器会将它自己的视图显示到导航界面并更新对应的导航控制。

    To remove a view controller from the stack programmatically, you call the popViewControllerAnimated: method. 

    使用编程方式从导航栈中移除一个视图控制器,你能够调用:popViewControllerAnimated: 方法。

    A navigation controller object tells its delegate about changes to the active view controller. You can assign a delegate to your navigation controller if you want to perform additional setup or cleanup tasks related to the pushing and popping of view controllers. The delegate object you provide must conform to the UINavigationControllerDelegate protocol.

    当活动的视图控制器发生变化时,导航控制会把这些变化通知给它的托付对象。

    假设你想运行一些附加的设置或者清理一些与视图控制器的push或pop操作相关的任务时,你能够指派一个托付对象给你的导航控制器。这个托付对象必须遵守UINavigationControllerDelegate协议。


    Navigation Controller Views

    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. 

    导航控制器是一个容器视图控制器——也就是说,它内部嵌入了其它视图控制器的内容。

    你能够通过view属性訪问导航控制器的view。这个view包含一个navigation bar、一个toolbar、和最顶层视图控制器的内容视图。


    The navigation controller manages the creation, configuration, and display of the navigation bar and optional navigation toolbar. It is permissible to customize the navigation bar’s appearance-related properties but you must never change its framebounds, or alpha values directly. If you subclass UINavigationBar, you must initialize your navigation controller using the initWithNavigationBarClass:toolbarClass: method. To hide or show the navigation bar, use the navigationBarHidden property or setNavigationBarHidden:animated: method.

    导航控制器管理着navigation bar和一个可选的toolbar的创建、配置和显示。

    它同意开发人员定制navigation bar显示相关的属性,可是你不能直接去改动它的frameboundsalpha值。假设你子类化了UINavigationBar。你必须使用initWithNavigationBarClass:toolbarClass:方法初始化你的导航控制器。显示或隐藏navigation bar,能够设置其navigationBarHidden属性。或使用setNavigationBarHidden:animated: 方法。


    A navigation controller builds the contents of the navigation bar dynamically using the navigation item objects (instances of the UINavigationItemclass) associated with the view controllers on the navigation stack. To change the contents of the navigation bar, you must therefore configure the navigation items of your custom view controllers. For more information about navigation items, see UINavigationItem Class Reference.

    导航控制器使用跟导航栈上的视图控制器相关联的navigation item对象(UINavigationItem类的实例)动态的构建navigation bar的内容,因此想要改变navigation bar的内容,你必须配置你自己定制的视图控制器的navigation items。关于
    navigation items的很多其它内容,请阅读UINavigationItem Class Reference。

    Updating the Navigation Bar

    When the user changes the top-level view controller, the navigation controller updates the navigation bar accordingly. Specifically, the navigation controller updates the bar button items displayed in each of the three navigation bar positions: left, middle, and right. Bar button items are instances of the UIBarButtonItem class. You can create items with custom content or create standard system items depending on your needs. For more information about how to create bar button items, see UIBarButtonItem Class Reference.

    当用户改变顶层视图控制器,导航控制器会对应更新navigation bar。也就是。导航控制器会更新显示在navigation bar左、中、右三个位置的button itemsBar button itemsUIBarButtonItem类的实例。

    你能够依据你的须要用自己定义的内容创建items。也能够创建系统标准的items。很多其它关于怎样创建button items的内容,请阅读UIBarButtonItem Class Reference


    For all but the root view controller on the navigation stack, the item on the left side of the navigation bar provides navigation back to the previous view controller. The contents of this left-most button are determined as follows:

    除了根视图控制器以外的其它全部视图控制器,navigation bar左側的item提供一个用于返回前一个视图控制器的导航button。

    这个最左側的button的内容由下面规则决定:


    • If the new top-level view controller has a custom left bar button item, that item is displayed. To specify a custom left bar button item, set the leftBarButtonItem property of the view controller’s navigation item.

    • 假设新的顶层视图控制器有一个定制的 left bar button item。那么这个item会显示。

      能够通过设置新的顶层视图控制器navigation item的leftBarButtonItem属性指定一个定制的left bar button item。


    • If the top-level view controller does not have a custom left bar button item, but the navigation item of the previous view controller has an object in its backBarButtonItem property, the navigation bar displays that item.

    • 假设顶层视图控制器没有定制的bar button item,可是前一个视图控制器navigation item的backBarButtonItem属性里面有一个对象,navigation bar将会显示这个item。


    • If a custom bar button item is not specified by either of the view controllers, a default back button is used and its title is set to the value of the title property of the previous view controller—that is, the view controller one level down on the stack. (If there is only one view controller on the navigation stack, no back button is displayed.)

    • 假设视图控制器都没有指定定制的bar button item,那么将会显示一个默认的返回button。它的标题会被设置为前一个视图控制器的title属性的值,前一个视图控制器也就是在导航栈中比当前视图控制器低一个层级的视图控制器。

      (假设仅有一个视图控制器在导航栈里面。那么返回button将不会显示。)



    NOTE

    In cases where the title of a back button is too long to fit in the available space, the navigation bar may substitute the string “Back” for the actual button title. The navigation bar does this only if the back button is provided by the previous view controller. If the new top-level view controller has a custom left bar button item—an object in the leftBarButtonItem or leftBarButtonItemsproperty of its navigation item—the navigation bar does not change the button title.
    假设返回button的标题太长,navigation bar可能会用“back”替换掉实际的button标题。这个替换仅仅发生在返回button由前一个视图控制器提供时。假设新的顶层视图控制器有一个定制的bar button item——navigation item的leftBarButtonItem 和 leftBarButtonItems属性有对象,navigation bar不会改动button标题。

    The navigation controller updates the middle of the navigation bar as follows:

    导航视图控制器遵从例如以下规则更新navigation bar的中间部分:

    • If the new top-level view controller has a custom title view, the navigation bar displays that view in place of the default title view. To specify a custom title view, set the titleView property of the view controller’s navigation item.

    • 假设新的顶层视图控制器有一个定制的title view,navigation bar会显示这个定制的title view替换掉默认的title view。能够通过设置视图控制器navigation item的titleView属性指定一个定制的title view。

    • If no custom title view is set, the navigation bar displays a label containing the view controller’s default title. The string for this label is usually obtained from the title property of the view controller itself. If you want to display a different title than the one associated with the view controller, set the title property of the view controller’s navigation item instead.

    • 假设没有设置定制的title view,navigation bar就显示包括视图控制器默认标题的一个标签。这个标签的字符串一般是从视图控制器自己的title属性获得的。假设你想显示一个与视图控制器相关联的标题不同样的标题。你能够设置视图控制器navigation item的title属性。


    The navigation controller updates the right side of the navigation bar as follows:

    导航视图控制器遵从例如以下规则更新navigation bar的右边部分:

    • If the new top-level view controller has a custom right bar button item, that item is displayed. To specify a custom right bar button item, set the rightBarButtonItem property of the view controller’s navigation item.

    • 假设新的顶层视图控制有一个定制的right bar button item。这个item将会被显示。能够通过设置视图控制器navigation item的rightBarButtonItem属性指定一个定制的right bar button item。


    • If no custom right bar button item is specified, the navigation bar displays nothing on the right side of the bar.

    • 假设没有定制的right bar button item,navigation bar的右側就什么都不会显示。

    The navigation controller updates the navigation bar each time the top view controller changes. Thus, these changes occur each time a view controller is pushed onto the stack or popped from it. When you animate a push or pop operation, the navigation controller similarly animates the change to the navigation bar content.

    导航控制器会在每次更新顶层视图控制器的时候更新navigation bar,也就是说,当视图控制器从导航栈push或pop时。这些变化都会发生。当你以动画一个push或pop操作。导航控制器也会相同的对navigation bar的内容动画这些变化。


    Tinting of the navigation bar is controlled by properties of the navigation bar itself. Use the tintColor property to change the tint color of items in the bar and use the barTintColor property to change the tint color of the bar itself. Navigation bars do not inherit their tint color from the currently displayed view controller.

    navigation bar的着色被它自己的属性控制。能够使用tintColor属性改变navigation baritemstint color,使用barTintColor属性改变navigation bar自身的tint color。

    navigation bar不会从当前显示的视图控制器来继承tint color


    For more information about the navigation bar, see UINavigationBar Class Reference.

    很多其它关于navigation bar的很多其它信息,请阅读UINavigationBar Class Reference。

    Displaying a Navigation Toolbar

    A navigation controller object manages an optional toolbar in its view hierarchy. When displayed, this toolbar obtains its current set of items from the toolbarItems property of the active view controller. When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.

    导航控制器在它的视图层级中管理着一个可选的toolbar。当这个toolbar显示的时候,它从活动的视图控制器的toolbarItems属性获取它当前的items的集合。

    当活动的视图控制器发生改变。导航控制器就会更新toolbaritems以匹配新的视图控制器,并动画新的items到合适的位置。


    The navigation toolbar is hidden by default but you can show it for your navigation interface by calling the setToolbarHidden:animated: method of your navigation controller object. If not all of your view controllers support toolbar items, your delegate object can call this method to toggle the visibility of the toolbar during subsequent push and pop operations. To use a custom UIToolbar subclass, use the initWithNavigationBarClass:toolbarClass: method to initialize the navigation controller.

    导航控制器的toolbar默认情况下是隐藏的,但你能够通过调用导航控制器的setToolbarHidden:animated:方法将它设置为显示。假设你并非全部的视图控制器都支持toolbar items,你能够在随后的push或pop操作时。用托付对象发送这个消息来让toolbar隐藏或显示。

    假设要使用一个自己定义的UIToolbar子类。须要使用initWithNavigationBarClass:toolbarClass: 方法初始化导航控制器。


    State Preservation

    In iOS 6 and later, if you assign a value to this view controller’s restorationIdentifier property, it attempts to preserve the child view controllers on its navigation stack. The navigation controller starts at the bottom of the stack and moves upward, encoding each view controller that also has a valid restoration identifier string. During the next launch cycle, the navigation controller restores the preserved view controllers to the navigation stack in the same order that they were preserved.

    iOS 6及之后的版本号,假设你给视图控制器的restorationIdentifier属性指定一个值,它会试图去保存它所在的导航栈里面的子视图控制器。导航控制器从栈底開始向上移动。编码每个有有效恢复标识字符串的视图控制器。在下一次的启动循环中。导航控制器依照之前保存的顺序恢复视图控制器到导航栈中。

    The child view controllers you push onto the navigation stack may use the same restoration identifiers. The navigation controller automatically stores additional information to ensure that each child’s restoration path is unique.

    被push到导航栈的子视图控制器可能使用同样的恢复标识符。导航控制器会自己主动保存额外的信息确保每个子恢复路径都是唯一的。


    For more information about how state preservation and restoration works, see App Programming Guide for iOS.

    很多其它关于状态保存和恢复的内容。请阅读App Programming Guide for iOS



  • 相关阅读:
    《iOS-LLVM框架》
    《尚硅谷大数据之韩顺平Scala》
    《高性能Java-缓存、序列化、String》
    《高性能Java-集合》
    《尚硅谷大数据课程Spark+Spark高级(内存解析+性能调优)》
    《Spatial Transformer Networks》
    《Relational inductive biases, deep learning, and graph networks》
    《[论文笔记]Relational inductive biases, deep learning, and graph network》
    SSD:TensorFlow中的单次多重检测器
    YOLO: 3 步实时目标检测安装运行教程 [你看那条狗,好像一条狗!]
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4819311.html
Copyright © 2011-2022 走看看