How to access the stack in UINavigationController(如何访问 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 中的堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何访问 UINavigationController 中的堆栈
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
