IOS 7 Study - Manipulating a Navigation Controller’s Array of View

简介: ProblemYou would like to directly manipulate the array of view controllers associated with aspecific navigation controller SolutionUse the viewContro...

Problem
You would like to directly manipulate the array of view controllers associated with a
specific navigation controller


Solution
Use the viewControllers property of the UINavigationController class to access and
modify the array of view controllers associated with a navigation controller

 

- (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开发 Go
IOS 7 Study - Implementing Navigation with UINavigationController
ProblemYou would like to allow your users to move from one view controller to the other witha smooth and built-in animation.
730 0
|
8天前
|
Python
使用array()函数创建数组
使用array()函数创建数组。
19 3
|
8天前
|
JavaScript 前端开发
总结TypeScript 的一些知识点:TypeScript Array(数组)(下)
一个数组的元素可以是另外一个数组,这样就构成了多维数组(Multi-dimensional Array)。
|
8天前
|
存储 JavaScript 前端开发
总结TypeScript 的一些知识点:TypeScript Array(数组)(上)
数组对象是使用单独的变量名来存储一系列的值。
|
8天前
|
存储 安全 Swift
在Swift中,数组(Array)
在Swift中,数组(Array)
32 3
|
8天前
|
Ruby
|
8天前
|
存储 索引 Python
多数pythoneer只知有列表list却不知道python也有array数组
多数pythoneer只知有列表list却不知道python也有array数组
27 0
|
8天前
|
JavaScript 前端开发 索引
在JavaScript中,可以使用数组字面量或Array构造函数来创建一个数组对象
【4月更文挑战第16天】在JavaScript中,可以使用数组字面量或Array构造函数来创建一个数组对象
24 4
|
6月前
|
算法 Python
数组倍增(Array Doubling
数组倍增(Array Doubling)是一种常见的算法技术,用于解决数组相关的查找、插入、删除等问题。该技术的核心思想是将数组的大小乘以 2,新数组的长度是原数组长度的两倍,然后将原数组中的元素复制到新数组中。在某些情况下,这种技术可以提高算法的效率,尤其是对于动态数据结构的问题。
141 1