如何从FirstViewController访问tabBarController?

时间:2010-07-03 01:47:59

标签: iphone

Tab Bar Application模板创建了一个新项目,如何从tabBarController访问AppDelegate(在FirstViewController中声明)?我想从视图控制器中读取tabBarController中的一些属性。谢谢!

1 个答案:

答案 0 :(得分:2)

您始终可以按如下方式访问应用代理:

[UIApplication sharedApplication].delegate

所以你应该能够通过这样做来获得tabBarController:

MyAppDelegate *delegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;

现在请参阅delegate.tabBarController。

[在上文中,MyAppDelegate是您为应用代表的类提供的任何名称。]