1

我正在为 iPhone 开发一个应用程序,我需要在其中发送消息topViewControllerrootViewController.

一种解决方案可能是在导航堆栈中的每个 VC 中创建委托方法并相应地调用,以便消息到达rootViewController. 但在这种情况下,消息必须通过整个导航堆栈。

任何机构都可以用最好的方法帮助我吗

谢谢

4

2 回答 2

2

一种选择是访问rootViewcontroller

RootViewController *rootViewController = (RootViewController *)[self.navigationController.viewControllers objectAtIndex:0];

然后对这个对象做必要的操作。navigationController.viewControllers返回导航堆栈中的所有视图控制器。

于 2012-12-05T09:44:05.770 回答
1

在任何 topViewController 方法中,您都可以通过以下方式提取导航堆栈的 rootViewController

 [self.navigationController.viewControllers objectAtIndex:0];
于 2012-12-05T09:46:10.663 回答