如何在UINavigationController中访问堆栈 [英] How to access the stack in UINavigationController
问题描述
viewControllers
目前在
导航堆栈上的视图控制器。
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 map。
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)];
另外请查看导航控制器文章,特别是修改导航堆栈一节。
In addition check out the Navigation Controllers article in the iOS Developer Library, specifically the section called 'Modifying the Navigation Stack'.
这篇关于如何在UINavigationController中访问堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!