美文网首页
UINavigationController

UINavigationController

作者: ngugg | 来源:发表于2019-05-28 14:03 被阅读0次
    #import <Foundation/Foundation.h>
    #import <CoreGraphics/CoreGraphics.h>
    #import <UIKit/UIViewController.h>
    #import <UIKit/UIKitDefines.h>
    #import <UIKit/UIInterface.h>
    #import <UIKit/UIGeometry.h>
    #import <UIKit/UIPanGestureRecognizer.h>
    #import <UIKit/UITapGestureRecognizer.h>
    
    /*!
     UINavigationController manages a stack of view controllers and a navigation bar.
     It performs horizontal view transitions for pushed and popped views while keeping the navigation bar in sync.
    UINavigationController管理一堆视图控制器和一个导航栏。
      它为push和pop视图执行水平视图过渡,同时保持导航栏同步。
     
     
     Most clients will not need to subclass UINavigationController.
    大多数客户端不需要子类UINavigationController。
     
     
     If a navigation controller is nested in a tabbar controller, it uses the title and toolbar attributes of the bottom view controller on the stack.
      如果导航控制器嵌套在tabbar控制器中,它将使用堆栈上底部视图控制器的标题和工具栏属性。
     
     
     UINavigationController is rotatable if its top view controller is rotatable.
     Navigation between controllers with non-uniform rotatability is currently not supported.
      如果UINavigationController的顶视图控制器是可旋转的,则它是可旋转的。
      目前不支持在具有不均匀可旋转性的控制器之间导航。
    */
    
      
    
    
    
    NS_ASSUME_NONNULL_BEGIN
    
    typedef NS_ENUM(NSInteger, UINavigationControllerOperation) {
        UINavigationControllerOperationNone,
        UINavigationControllerOperationPush,
        UINavigationControllerOperationPop,
    };
    
    UIKIT_EXTERN const CGFloat UINavigationControllerHideShowBarDuration;
    
    @class UIView, UINavigationBar, UINavigationItem, UIToolbar;
    @protocol UINavigationControllerDelegate;
    
    
    NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationController : UIViewController
    
    
    /* Use this initializer to make the navigation controller use your custom bar class. 
       Passing nil for navigationBarClass will get you UINavigationBar, nil for toolbarClass gets UIToolbar.
       The arguments must otherwise be subclasses of the respective UIKit classes.
    使用此初始化程序使导航控制器使用您的自定义栏类。
        为navigationBarClass传递nil将获得UINavigationBar,toolbarClass的nil获取UIToolbar。
        否则参数必须是相应UIKit类的子类
     */
    - (instancetype)initWithNavigationBarClass:(nullable Class)navigationBarClass toolbarClass:(nullable Class)toolbarClass NS_AVAILABLE_IOS(5_0);
    
    // 便捷方法在没有动画的情况下推动根视图控制器。
    - (instancetype)initWithRootViewController:(UIViewController *)rootViewController; // Convenience method pushes the root view controller without animation.
    
    // 使用水平幻灯片过渡。 如果视图控制器已在堆栈中,则无效。
    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; // Uses a horizontal slide transition. Has no effect if the view controller is already in the stack.
    
    // 返回弹出的控制器。
    - (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated; // Returns the popped controller.
    
    // 弹出视图控制器,直到指定的控制器位于顶部。 返回弹出的控制器。
    - (nullable NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; // Pops view controllers until the one specified is on top. Returns the popped controllers.
    
    // 弹出,直到堆栈上只剩下一个视图控制器。 返回弹出的控制器。
    - (nullable NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated; // Pops until there's only a single view controller left on the stack. Returns the popped controllers.
    
    // 堆栈上的顶视图控制器。
    @property(nullable, nonatomic,readonly,strong) UIViewController *topViewController; // The top view controller on the stack.
    
    // 返回模态视图控制器(如果存在)。 否则顶视图控制器。
    @property(nullable, nonatomic,readonly,strong) UIViewController *visibleViewController; // Return modal view controller if it exists. Otherwise the top view controller.
    
    // 当前视图控制器堆栈。
    @property(nonatomic,copy) NSArray<__kindof UIViewController *> *viewControllers; // The current view controller stack.
    
    // 如果动画为YES,则根据新的顶视图控制器先前是否在堆栈中来模拟推送或弹出。
    - (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.
    
    // 隐藏或显示导航栏。 如果是动画,它将使用UINavigationControllerHideShowBarDuration垂直过渡。
    @property(nonatomic,getter=isNavigationBarHidden) BOOL navigationBarHidden;
    - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated; // Hide or show the navigation bar. If animated, it will transition vertically using UINavigationControllerHideShowBarDuration.
    
    // 导航栏由控制器管理。 不支持在托管导航栏上推送,弹出或设置导航项。
    @property(nonatomic,readonly) UINavigationBar *navigationBar; // The navigation bar managed by the controller. Pushing, popping or setting navigation items on a managed navigation bar is not supported.
    
    @property(nonatomic,getter=isToolbarHidden) BOOL toolbarHidden NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // Defaults to YES, i.e. hidden.
    
    // 隐藏或显示屏幕底部的工具栏。 如果是动画,它将使用UINavigationControllerHideShowBarDuration垂直过渡。
    - (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // Hide or show the toolbar at the bottom of the screen. If animated, it will transition vertically using UINavigationControllerHideShowBarDuration.
    
    // 用于提交活动表时使用。
    @property(null_resettable,nonatomic,readonly) UIToolbar *toolbar NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // For use when presenting an action sheet.
    
    @property(nullable, nonatomic, weak) id<UINavigationControllerDelegate> delegate;
    @property(nullable, nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    
    // 解释为pushViewController:animated:
    - (void)showViewController:(UIViewController *)vc sender:(nullable id)sender NS_AVAILABLE_IOS(8_0); // Interpreted as pushViewController:animated:
    
    // 键盘出现时,将隐藏导航控制器导航栏工具栏。 当键盘解除时,导航栏将保持隐藏状态,但点击内容区域将显示它们。
    /// When the keyboard appears, the navigation controller's navigationBar toolbar will be hidden. The bars will remain hidden when the keyboard dismisses, but a tap in the content area will show them.
    @property (nonatomic, readwrite, assign) BOOL hidesBarsWhenKeyboardAppears NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    // 当用户滑动时,导航控制器导航栏和工具栏将被隐藏(在向上滑动时)或显示(在向下滑动时)。 只有具有项目的工具栏才会参与。
    /// When the user swipes, the navigation controller's navigationBar & toolbar will be hidden (on a swipe up) or shown (on a swipe down). The toolbar only participates if it has items.
    @property (nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    // 如果导航栏由于滑动而隐藏或显示,则触发手势识别器。 请勿更改委托或尝试通过重写此方法来替换此手势。
    /// The gesture recognizer that triggers if the bars will hide or show due to a swipe. Do not change the delegate or attempt to replace this gesture by overriding this method.
    @property (nonatomic, readonly, strong) UIPanGestureRecognizer *barHideOnSwipeGestureRecognizer NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    // 当UINavigationController的垂直大小类是紧凑的时,隐藏UINavigationBar和UIToolbar。 通常被这些条占据的区域中未处理的水龙头将显示条形
    /// When the UINavigationController's vertical size class is compact, hide the UINavigationBar and UIToolbar. Unhandled taps in the regions that would normally be occupied by these bars will reveal the bars.
    @property (nonatomic, readwrite, assign) BOOL hidesBarsWhenVerticallyCompact NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    
    /// When the user taps, the navigation controller's navigationBar & toolbar will be hidden or shown, depending on the hidden state of the navigationBar. The toolbar will only be shown if it has items to display.
    // 当用户点击时,导航控制器的navigationBar和工具栏将被隐藏或显示,具体取决于navigationBar的隐藏状态。 只有具有要显示的项目时才会显示工具栏。
    @property (nonatomic, readwrite, assign) BOOL hidesBarsOnTap NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    /// The gesture recognizer used to recognize if the bars will hide or show due to a tap in content. Do not change the delegate or attempt to replace this gesture by overriding this method.
    // 手势识别器用于识别由于内容中的点击而使导航栏隐藏或显示。 请勿更改委托或尝试通过重写此方法来替换此手势。
    @property (nonatomic, readonly, assign) UITapGestureRecognizer *barHideOnTapGestureRecognizer NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
    
    @end
    
    @protocol UIViewControllerInteractiveTransitioning;
    @protocol UIViewControllerAnimatedTransitioning;
    
    @protocol UINavigationControllerDelegate <NSObject>
    
    @optional
    
    // Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.
    // 当导航控制器通过视图控制器堆栈的push,pop或setting显示新的顶视图控制器时调用。
    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
    
    - (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    - (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    
    - (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
                              interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController NS_AVAILABLE_IOS(7_0);
    
    - (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                       animationControllerForOperation:(UINavigationControllerOperation)operation
                                                    fromViewController:(UIViewController *)fromVC
                                                      toViewController:(UIViewController *)toVC  NS_AVAILABLE_IOS(7_0);
    
    @end
    
    @interface UIViewController (UINavigationControllerItem)
    
    // 按需创建,以便视图控制器可以自定义其导航外观。
    @property(nonatomic,readonly,strong) UINavigationItem *navigationItem; // Created on-demand so that a view controller may customize its navigation appearance.
    
    // 如果是,则当此视图控制器被推入具有底栏的控制器层次结构(如标签栏)时,底栏将滑出。 默认为NO。
    @property(nonatomic) BOOL hidesBottomBarWhenPushed __TVOS_PROHIBITED; // If YES, then when this view controller is pushed into a controller hierarchy with a bottom bar (like a tab bar), the bottom bar will slide out. Default is NO.
    
    // 如果此视图控制器已被推送到导航控制器,请将其返回。
    @property(nullable, nonatomic,readonly,strong) UINavigationController *navigationController; // If this view controller has been pushed onto a navigation controller, return it.
    
    @end
    
    @interface UIViewController (UINavigationControllerContextualToolbarItems)
    
    @property (nullable, nonatomic, strong) NSArray<__kindof UIBarButtonItem *> *toolbarItems NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;
    - (void)setToolbarItems:(nullable NSArray<UIBarButtonItem *> *)toolbarItems animated:(BOOL)animated NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;
    
    @end
    
    

    相关文章

      网友评论

          本文标题:UINavigationController

          本文链接:https://www.haomeiwen.com/subject/fpxdtctx.html