zoukankan      html  css  js  c++  java
  • UI整理-----part8--导航控制器(navigationController)

    ---恢复内容开始---

    (1)UINavigationController通常被称作导航控制栏,是视图与视图之间沟通联系的桥梁,是个类的控制器,用来管理试图控制器的切换,导航栏是一个导航控制器共用的。

    (2)导航控制器用来管理其他控制器显示视图,本身是不显示视图内容的。

    (3)导航控制器主要用来控制多控制器的连续切换

    (4)U

    ---恢复内容结束---

    (1)UINavigationController通常被称作导航控制栏,是视图与视图之间沟通联系的桥梁,是个类的控制器,用来管理试图控制器的切换,导航栏是一个导航控制器共用的。

    (2)导航控制器用来管理其他控制器显示视图,本身是不显示视图内容的。

    (3)导航控制器主要用来控制多控制器的连续切换

    (4)UINavigationController继承于UIViewController,以栈的方式管理所控制的视图控制器,至少要有一个被管理的视图控制器,这个控制器称作导航控制器的根视图控制器。任何继承自UIViewController的类(多态)都可以作为根视图控制器。

    (5)UINavigationController的ControllersView里始终显示栈顶端控制器的View

    (6)ViewControllers属性存储了栈中所有被管理的控制器。

    (7)navigationController属性是父类中的属性,每一个在栈中的控制器都能通过此属性获取自己所在的UINavigationController对象。

    (8)出栈和入栈的方法:

            <1>- (void)pushViewController:(UIViewController *)viewControlleranimated:(BOOL)animated;  进入下一个试图控制器

            <2>- (nullableUIViewController *)popViewControllerAnimated:(BOOL)animated;  返回上一个视图控制器

            <3>- (nullableNSArray<__kindofUIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated;  返回到指定的试图控制器

            <4>- (nullableNSArray<__kindofUIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated;  返回到根视图控制器

    (9)初始化的具体过程:

    (10)常用属性:

            <1>@property(nonatomic,copy) NSArray<__kindofUIViewController *> *viewControllers;  所有处于栈中的控制器

            <1>@property(nullable, nonatomic,readonly,strong) UIViewController *topViewController;  位于栈顶的控制器

            <1>@property(nullable, nonatomic,readonly,strong) UIViewController *visibleViewController;  当前正在显示的控制器

            <1>@property(nonatomic,readonly) UINavigationBar *navigationBar;  导航条

    (11)UINavigationBar:navigationBar 导航条 iOS7以后默认是透明的,以前默认是不透明的,navigationBar在透明情况下与contentView会重合一部分区域,在不透明情况下,contentView跟在navigationBar下面,navigationBar竖屏状态下默认高度44,横屏下默认32。

    (12)注意:

    <1>不管是在哪个ViewController里更改self.navigationController属性,他们都是更改的同一个导航控制器。

    <2>设置导航栏的时候一定要self.navigationController.navigationBar(作用全局)。

    <3>导航项(item)仅作用于单个界面,是各自管理的。

    (13)导航栏属性的学习

              <1>常用属性:

    self.navigationController.navigationBar._______

              @property(nonatomic,assign,getter = isTranslucent) BOOL translucent;  设置属性为透明或半透明,默认半透明(设置颜色后失效)

             @property(nullable, nonatomic,strong) UIColor *barTintColor;设置导航栏的颜色,默认为nil

    self.navigationController._______

             @property(nonatomic,getter=isNavigationBarHidden) BOOL navigationBarHidden;  隐藏导航栏

             @property(nonatomic,getter=isToolbarHidden) BOOLtoolbarHidden; toolBar(工具栏) 的隐藏状态,默认为YES;

              <2>设置导航栏背景图片,设置以后不会显示透明状态:

    self.navigationController.navigationBar._______

    - (nullable UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics;

      typedefNS_ENUM(NSInteger, UIBarMetrics) {

        UIBarMetricsDefault,  竖屏时UINavigationBar标准的尺寸显示NavigationBar             

        UIBarMetricsCompact,

        UIBarMetricsDefaultPrompt = 101,  

        UIBarMetricsLandscapePhone NS_ENUM_DEPRECATED_IOS(5_0, 8_0, "UseUIBarMetricsCompactinstead") = UIBarMetricsCompact,   横屏时UINavigationBar标准的尺寸显示NavigationBar

        UIBarMetricsLandscapePhonePrompt  NS_ENUM_DEPRECATED_IOS(7_0, 8_0, "UseUIBarMetricsCompactPrompt") = UIBarMetricsCompactPrompt,

        };

              <3>UINavigationControllerDelegate:self.navigationController.delegate = self

    - (void)navigationController:(UINavigationController *)navigationControllerwillShowViewController:(UIViewController *)viewControlleranimated:(BOOL)animated;  导航控制器即将显示视图控制器

    - (void)navigationController:(UINavigationController *)navigationControllerdidShowViewController:(UIViewController *)viewControlleranimated:(BOOL)animated;  导航控制器已经显示视图控制器

     

     

    (14)导航项:@property(nonatomic,readonly,strong) UINavigationItem *navigationItem   

              <1>@property(nullable, nonatomic,copy)NSString *title;  给中间的title设置内容

              <2>创建自定义标题

    UIBarButtonItem *item = [[UIBarButtonItemalloc] initWithTitle:<#(nullableNSString *)#> style:<#(UIBarButtonItemStyle)#> target:<#(nullableid)#> action:<#(nullableSEL)#>];

        typedefNS_ENUM(NSInteger, UIBarButtonItemStyle) {

        UIBarButtonItemStylePlain,

        UIBarButtonItemStyleBordered,

        UIBarButtonItemStyleDone,

        };   UIBarButtonItemStylePlain 和 UIBarButtonItemStyleBordered 效果看起来一样

              <3>创建系统推荐样式的导航项:

    UIBarButtonItem *item = [[UIBarButtonItemalloc] initWithBarButtonSystemItem:<#(UIBarButtonSystemItem)#> target:<#(nullableid)#> action:<#(nullableSEL)#>];

    按钮样式有:

        typedefNS_ENUM(NSInteger, UIBarButtonSystemItem) {

        UIBarButtonSystemItemDone,   蓝色文字按钮,标有“done”

        UIBarButtonSystemItemCancel,    文字按钮,标有“cancel”

        UIBarButtonSystemItemEdit,     文字按钮,标有“Edit”

        UIBarButtonSystemItemSave,       蓝色文字按钮,标有“Save”

        UIBarButtonSystemItemAdd,       图像按钮,上有一个add符号

        UIBarButtonSystemItemFlexibleSpace,     空白,占有空间大小可变

        UIBarButtonSystemItemFixedSpace,       空白占位符

        UIBarButtonSystemItemCompose,        图像按钮,上有一张纸和一支笔

        UIBarButtonSystemItemReply,        图像按钮,上有一个回复箭头

        UIBarButtonSystemItemAction,   图像按钮,上有一个动作箭头

        UIBarButtonSystemItemOrganize,      图像按钮,上有一个文件夹及向下箭头

        UIBarButtonSystemItemBookmarks,        图像按钮,上有书签图标

        UIBarButtonSystemItemSearch,           图像按钮,上有spotlight图标

        UIBarButtonSystemItemRefresh,             图像按钮,上有环形的刷新箭头

        UIBarButtonSystemItemStop,                图像按钮,上有一个停止记号 “×”

        UIBarButtonSystemItemCamera,                    图像按钮,上有一个照相机

        UIBarButtonSystemItemTrash,                     图像按钮,上有一个垃圾桶

        UIBarButtonSystemItemPlay,                      图像按钮,上有一个播放图标

        UIBarButtonSystemItemPause,                           图像按钮,上有一个暂停图标

        UIBarButtonSystemItemRewind,                               图像按钮,上有一个倒带图标

        UIBarButtonSystemItemFastForward,                            上有一个快进图标

        UIBarButtonSystemItemUndo  NS_ENUM_AVAILABLE_IOS(3_0),

        UIBarButtonSystemItemRedo  NS_ENUM_AVAILABLE_IOS(3_0),

        UIBarButtonSystemItemPageCurl   NS_ENUM_AVAILABLE_IOS(4_0),

        };

              <4>自定义视图按钮

        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:<#(UIBarButtonSystemItem)#> target:<#(nullableid)#> action:<#(nullableSEL)#>];

        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

        button.frame = CGRectMake(<#CGFloatx#>, <#CGFloaty#>, <#CGFloatwidth#>, <#CGFloatheight#>);

        [button setImage:<#(nullableUIImage *)#> forState:<#(UIControlState)#>];

        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];

        self.navigationItem.leftBarButtonItem = item;( 也可以是@[button1,button2])

  • 相关阅读:
    (续)在深度计算框架MindSpore中如何对不持续的计算进行处理——对数据集进行一定epoch数量的训练后,进行其他工作处理,再返回来接着进行一定epoch数量的训练——单步计算
    YAML文件简介
    训练集验证集测试集的概念
    泛化误差
    drawio的打开方法
    移动硬盘无法被电脑识别
    r5 3600相当于英特尔什么级别
    Ubuntu WPS字体缺失配置
    pytorch深度学习cpu占用太高
    常用的架构设计原则-云原生架构设计快速入门
  • 原文地址:https://www.cnblogs.com/8023huihui/p/5213720.html
Copyright © 2011-2022 走看看