Question

I have an iOS application that uses three different navigation controllers that are embedded within a Tab Bar Controller. Pretty simple stuff.

How do I block user interface from these tab items? Is it possible? I want to have a log out button be able to essentially lock out the user from selecting tab items or anything else on the view controller until the log out action is finished.

Added 1/16/14:

If the classes you need to do this in are subclasses of UIViewControllers, you can simply implement the following:

self.tabBarController.tabBar.userInteractionEnabled = NO;
self.tabBarController.tabBar.hidden = YES;
Was it helpful?

Solution

There is a dedicated method in UITabBarControllerDelegate for this:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

Just return NO if you don't want the user to be able to select a given tab bar item.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top