Reputation: 49
I want to disable and enable later an UITabbarItem from the AppDelegate.m. (To be specific, on didFinishLaunchingWithOptions should it be disabled and after a NSURLConnection it should be enabled. I already tried creating a external method in the First View Controller and calling it from the Delegate, but it do not work. Here is my attempt:
FirstViewController.m:
-(void)enableDataTab {
[[[[self.tabBarController tabBar] items] objectAtIndex:1] setEnabled:YES];
}
AppDelegate.m:
homeVC = [[FirstViewController alloc] init];
[homeVC disableDataTab];
Upvotes: 0
Views: 186
Reputation: 534885
Like this (in the view controller):
self.tabBarItem.enabled = NO;
Or like this (in the app delegate):
myFirstViewController.tabBarItem.enabled = NO;
The tab bar item representing a view controller is a property of that view controller.
Also, don't say
homeVC = [[FirstViewController alloc] init];
That makes a whole new FirstViewController. You don't want a new FirstViewController; you want the one that's already there as a child of the tab bar controller.
Upvotes: 1