开发者

How to access the tabBarController from FirstViewController?

开发者 https://www.devze.com 2023-01-05 19:22 出处:网络
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 tab

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

精彩评论

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