如何访问 UINavigationController 中的堆栈 [英] How to access the stack in UINavigationController

查看:12
本文介绍了如何访问 UINavigationController 中的堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前的视图控制器导航堆栈.

viewControllers

The view controllers currently on the navigation stack.

@property(nonatomic, copy) NSArray * viewControllers

讨论

根视图控制器在索引 0 处数组,后视图控制器位于索引 n-2,顶部控制器是在索引 n-1 处,其中 n 是数组中的项目.

The root view controller is at index 0 in the array, the back view controller is at index n-2, and the top controller is at index n-1, where n is the number of items in the array.

分配一个新的视图数组该属性的控制器是相当于调用setViewControllers:animated: 方法动画参数设置为 NO.

Assigning a new array of view controllers to this property is equivalent to calling the setViewControllers:animated: method with the animated parameter set to NO.

我很困惑如何访问堆栈我在导航控制器中有三个视图——根视图控制器、sti 测试位置、sti 地图.

I am confused how to access the the stack I have three views in the navigation controller – root view controller, sti testing location, sti map.

如何访问堆栈?

推荐答案

UINavigationControllers 有一个名为 viewControllers 的属性,如上所述.由于这是一个视图控制器数组,因此在此层次结构中引用特定视图控制器与访问数组中的任何其他对象没有什么不同.

UINavigationControllers have a property called viewControllers as you have stated above. Since this is an array of View Controllers, referencing a specific view controller in this hierarchy is no different than accessing any other object in an array.

UIViewController *theControllerYouWant = [self.navigationController.viewControllers objectAtIndex:(theIndexOfYourViewController)];

另外查看 导航控制器 iOS 开发人员库中的文章,特别是名为修改导航堆栈"的部分.

In addition check out the Navigation Controllers article in the iOS Developer Library, specifically the section called 'Modifying the Navigation Stack'.

这篇关于如何访问 UINavigationController 中的堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆