开发者

How to access the tabBarController from FirstViewController?

Created a new project from the Tab Bar Application template, how can I access tabBarController (which is declared in AppDelegate) from FirstViewController? I'd like to read some attributes in the tabBarController from the view controller. Thanks!开发者_Python百科


You can always access the app delegate as follows:

[UIApplication sharedApplication].delegate

So you should be able to get at the tabBarController by doing this:

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

Now refer to delegate.tabBarController.

[In the above, MyAppDelegate is whatever name you gave the class of your app delegate.]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜