简体   繁体   English

iOS:从AppDelegate访问导航视图控制器

[英]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.

相关问题 iOS - 在 AppDelegate 中访问导航 Controller - iOS - Access Navigation Controller in AppDelegate iOS在AppDelegate中访问模式视图 - IOS Accessing a Modal View in AppDelegate 从AppDelegate导航到视图控制器不会禁用以前的视图控制器的音频播放 - Navigation from AppDelegate to a view controller don't disable the audio playing of previous view controller 如何从视图控制器访问AppDelegate中声明的Navigation Controller? - How do I access Navigation Controller declared in AppDelegate from view controller? iOS - 从appDelegate访问storyboard上的viewControllers - iOS - Accessing viewControllers on storyboard from appDelegate 无法从AppDelegate提供视图控制器 - Unable to present a view controller from AppDelegate 无法从appDelegate在View Controller中接收NSNotification - NSNotification not receiving in View Controller from appDelegate 从appdelegate发送消息到视图控制器 - Send message from appdelegate to view controller 从AppDelegate呈现特定的视图控制器 - Presenting a specific view controller from AppDelegate iOS:无法从AppDelegate添加子视图 - iOS: Adding sub view from AppDelegate not loading
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM