• 手动操作导航控制器的子视图控制器的数组


    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处.
    假设认为写的不好请多提意见,假设认为不错请多多支持点赞.谢谢! hopy ;)


    免责申明:本博客提供的全部翻译文章原稿均来自互联网。仅供学习交流之用。请勿进行商业用途。

    同一时候。转载时不要移除本申明。如产生不论什么纠纷,均与本博客全部人、发表该翻译稿之人无不论什么关系。谢谢合作!

    你可能希望直接操作与特定导航控制器相关的子视图控制器的数组.

    你能够使用UINavigationController的viewControllers属性改动其相关联的子视图控制器:

    - (void) goBack{
    /* Get the current array of View Controllers */
    NSArray *currentControllers = self.navigationController.viewControllers;
            /* Create a mutable array out of this array */
            NSMutableArray *newControllers = [NSMutableArray
                                              arrayWithArray:currentControllers];
            /* Remove the last object from the array */
            [newControllers removeLastObject];
            /* Assign this array to the Navigation Controller */
            self.navigationController.viewControllers = newControllers;
        }

    你能够不论什么视图控制器中调用该方法去弹出继承体系中最后(最后push入的,猫猪注)的导航控制器的子视图控制器.

    UINavigationController类的实例都持有一个数组对象,当中每个元素皆为一个UIViewController对象.在获取到该数组之后,你能够以你希望的不论什么方式手动操作该数组.比方说,你能够删除该继承体系数组中的一个视图控制器.

    可是直接操作这个UIViewController的数组并不会呈现给用户动画效果,假设你希望操作动画化,能够使用UINavigationController类的setViewControllers:animated:方法,代码例如以下:

    - (void) goBack{
    /* Get the current array of View Controllers */
    NSArray *currentControllers = self.navigationController.viewControllers;
    /* Create a mutable array out of this array */
            NSMutableArray *newControllers = [NSMutableArray
                                              arrayWithArray:currentControllers];
            /* Remove the last object from the array */
            [newControllers removeLastObject];
            /* Assign this array to the Navigation Controller with animation */
            [self.navigationController setViewControllers:newControllers
                                                 animated:YES];
    }
  • 相关阅读:
    IOS开发之----协议与委托(Protocol and Delegate) 实例解析
    iOS开发-Protocol协议及委托代理(Delegate)传值
    android内置存储器memory和第三方外部存储disk管理
    余弦信号DFT频谱分析(继续)
    3.1存储管理操作系统
    android变化HOLO对话风格
    Coco2d-x android win7 Python 游戏开发环境的搭建
    ITIL该研究的结论(互联网思维的结合)
    亚马逊记AWS(Amazon Web Services)自由EC2应用
    oracle触发农产品证明文件号码
  • 原文地址:https://www.cnblogs.com/clnchanpin/p/7056202.html
Copyright © 2020-2023  润新知