Goal C: How to disable user interaction with all tabs except one?

As the name suggests, I would like to be able to lock all my tab panels except one. And only after the user completes the action, I will turn on all the other tab panels. How can i do this?

+4
source share
3 answers

I have not tried, but according to docs you can return NO from the delegate tabBarController:shouldSelectViewController:

[UPDATE] I just tried this out of curiosity - everything seems to be fine. Create a new project from the Tab Bar app template, and then go to -viewDidLoad your FirstViewController. Add this line:

 [self.tabBarController setDelegate:self]; 

and then implement the delegation method:

 -(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { if (userHasCompletedAction) { return YES; } return NO; } 

Remember to specify <UITabBarControllerDelegate> in your .h file!

Hope this helps.

+15
source

You must implement this method

 - (void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController { if ([tabBarController1 selectedIndex]==0) { UITabBarItem *tabBarItem = [[[[self tabBarController]tabBar]items] objectAtIndex:1]; [tabBarItem setEnabled:FALSE]; } } 

You need to do something like this to turn off the necessary time sheet elements.

+4
source

The tabBar:didSelectItem: method in UITabBarDelegate can help.

0
source

All Articles