Reputation: 1004
I have a tabbar on my main window. Each individual tab item has its own view. How can enable/disable other tab items from another tab item view?
Upvotes: 1
Views: 2293
Reputation: 51374
You can access the tabBarItems only by using the view controllers in the tabBarController. Use the following code to disable tabBarItem 1, from any view controller.
UIViewController *vc_1;
vc_1 = [self.tabBarController.viewControllers objectAtIndex:1];
[vc_1 tabBarItem].enabled = NO;
Upvotes: 5
Reputation: 6286
in your viewcontroller you can do:
self.tabBarController
this gives you the tabbar controller in which the viewcontroller resides. From there you can access other viewcontrollers, the tabs etc etc.
Upvotes: 0
Reputation: 2186
I guess u want to change the settings of the objects u have in other tab. U can achieve this using NSUserDefaults or by passing the value to the view where u want to change the settings. Consider an example where u want to disable a button in another tab from the current tab view. Just set an NSUserDefaults to a certain value and assign it to a key. U can access the value u set for the particular key in another view again by using NSUserDefaults. U can check whether the value is what u set in viewWillAppear method of the other tab view. And based on that condition u can enable or disable the controls. Hope this helps.
Upvotes: 0