如何迭代应用程序上的所有UIViewControllers [英] How to iterate all the UIViewControllers on the app

查看:113
本文介绍了如何迭代应用程序上的所有UIViewControllers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这种结构的xib:

I have a xib with this structure:

- Tab Bar Controller
-- Tab Bar
-- NavigationController
--- Navigation Bar
--- News List View Controller
---- Navigation Item
--- Tab Bar Item

-- NavigationController
--- Navigation Bar
--- News List View Controller
---- Navigation Item
--- Tab Bar Item
-- NavigationController
--- Navigation Bar
--- News List View Controller
---- Navigation Item
--- Tab Bar Item
[...]

如何编写循环以在每次迭代中获取每个UIViewController(新闻列表视图控制器)?

How can I code a loop to take each UIViewController (News List View Controller) in each iteration?

推荐答案

像这样以代码方式访问它们:

Access them codewise like this:

NSArray * controllerArray = [[self navigationController] viewControllers];

for (UIViewController *controller in controllerArray){
   //Code here.. e.g. print their titles to see the array setup;
   NSLog(@"%@",controller.title);
}

这篇关于如何迭代应用程序上的所有UIViewControllers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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