如何访问 UINavigationController 中的堆栈

How to access the stack in UINavigationController(如何访问 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 中的堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)