[英]iOS: Accessing Navigation View Controller From AppDelegate
How to access navigation controller from the AppDelegate? 如何从AppDelegate访问导航控制器?
Suppose I have the following viewControllers: 假设我有以下viewControllers:
NavViewController -> UIViewController -> NavViewController -> UIViewController -> NavViewController -> UITableViewController NavViewController-> UIViewController-> NavViewController-> UIViewController-> NavViewController-> UITableViewController
In AppDelegate.m, how can I access the UITableViewController? 在AppDelegate.m中,如何访问UITableViewController?
I just know how to access the first ViewController using the below code: 我只知道如何使用以下代码访问第一个ViewController:
UINavigationController *navigationController = (UINavigationController)[self.window.rootViewController navigationController];
UIViewController *viewController1 = (UIViewController)[navigationController viewControllers]objectAtIndex:0];
but can someone teach me how to access the UITableViewController and the second UIViewController From the AppDelegate.m? 但是有人可以教我如何从AppDelegate.m访问UITableViewController和第二个UIViewController吗?
NavViewController -> UIViewController -> NavViewController -> UIViewController -> NavViewController -> UITableViewController NavViewController-> UIViewController-> NavViewController-> UIViewController-> NavViewController-> UITableViewController
You should never have this. 你永远不应该拥有这个。 I don't even know if this is possible. 我什至不知道这是否可能。 You should only have ONE UINavigationController. 您应该只有一个UINavigationController。 Maybe you were just displaying your setup in an odd way. 也许您只是以一种奇怪的方式显示了您的设置。
You could access the second UIViewController from the app delegate like this: 您可以像这样从应用程序委托访问第二个UIViewController:
UIViewController *viewController2 = (UIViewController *)[navigationController viewControllers]objectAtIndex:1];
And the UITableViewController like this: 和UITableViewController是这样的:
UITableViewController *viewController3 = (UITableViewController *)[navigationController viewControllers]objectAtIndex:2];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.