Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:39:49+00:00 2026-06-06T23:39:49+00:00

I’ve built my app with storyboards and all views are managed by a tabbarcontroller.

  • 0

I’ve built my app with storyboards and all views are managed by a tabbarcontroller.

So on launch (I’m only working on the iPad UI currently) it does this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
        UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
        UISplitViewController *splitViewController = [tabBarController.viewControllers objectAtIndex:0];
        UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
        splitViewController.delegate = (id)navigationController.topViewController;

        UINavigationController *masterNavigationController = [splitViewController.viewControllers objectAtIndex:0];
        ProductionMasterViewController *controller = (ProductionMasterViewController *)masterNavigationController.topViewController;
        controller.managedObjectContext = self.managedObjectContext;
    }
}

I want to be able to enable or disable the tabs in the tabBarController based on user input (so, for example, an item needs to be selected in the first tab in order to access the second and third tabs, which are disabled by default)

What I’m not clear on is how to access the tabs in order to enable/disble them. Would I create an instance of the appdelegate and then do something like

AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tabs = (UITabBarController *)[d.window rootViewController];
[[[[tabs tabBar] items] objectAtIndex:2] setEnabled:YES];
[[[[tabs tabBar] items] objectAtIndex:3] setEnabled:YES];
[[[[tabs tabBar] items] objectAtIndex:4] setEnabled:YES];

(That kinda seems like it should work but it also seems fairly gross.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:39:50+00:00Added an answer on June 6, 2026 at 11:39 pm

    Since you’re using a Storyboard based app, I’d assume you have the UITabBarController defined in the storyboard as the root controller. Incidentally, you can also retrieve it by identifier instead of walking from the window to the root view controller.

    Restricting which tabs are selectable, is achieved by setting a delegate of the UITabBarController (i.e. one that conforms to UITabBarControllerDelegate).

    In the delegate, you can implement these two methods:

    – tabBarController:shouldSelectViewController:

    – tabBarController:didSelectViewController:

    Likely, you just need the first to restrict (inhibit) selection, until your workflow is ready.

    Another approach, is to set the “viewControllers’ property on the tab bar controller, each time a milestone is passed. At each milestone, you set a more expansive array of view controllers into this property, which will open up the selection of the additional tab item.

    SWIFT 3

    (expanded for ease of understanding)

    let arrayOfTabBarItems = tabBarController?.tabBar.items
    
            if let barItems = arrayOfTabBarItems, barItems.count > 0 {
                os_log("barItems.count is now ", barItems.count)
                tabBarItem0 = barItems[0]
                tabBarItem0.isEnabled = true
                tabBarItem1 = barItems[1]
                tabBarItem1.isEnabled = true
                tabBarItem2 = barItems[2]
                tabBarItem2.isEnabled = true
                tabBarItem3 = barItems[3]
                tabBarItem3.isEnabled = true
                tabBarItem4 = barItems[4]
                tabBarItem4.isEnabled = true
            }
    

    This can be used in your viewWillAppear on each tab controller. Check your rules against this and restrict each tab accordingly.
    (more concise method)

    let arrayOfAllTabBarItems = tabBarController?.viewControllers
        if   let tabBarArray = arrayOfAllTabBarItems, tabBarArray.count > 0 {
            for x in 0...tabBarArray.count-1 {
                let tabBarItem = tabBarArray[x]
                if tabBarItem.title != nil {
                    if tabBarItem.title == "Tab1" || tabBarItem.title == "MyTab" || tabBarItem.title == "Tab2Check" {
                        tabBarItem.tabBarItem.isEnabled = !(isMyRuleTrue!)
                    }
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.