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.]
精彩评论