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 8114791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:15:38+00:00 2026-06-06T03:15:38+00:00

So In my app, I use a storyboard, and the initial viewController is a

  • 0

So In my app, I use a storyboard, and the initial viewController is a UITabBarController. What I want to do is when the app launches, I want to be able to set wheather the tabBarController has 3 items or 4. So in the appDel, I plan to check weather that user should see 3 or 4 tabs, and then the tabBarController should reflect that.

I tried subclassing the tabBarController, but the its not working:

@implementation TabBarController

-(id) init{
    if ((self = [super init])) {
        [[[[self tabBar] items] objectAtIndex:2] setEnabled:YES];
        [[[[self tabBar] items] objectAtIndex:3] setEnabled:NO];
        [[[[self tabBar] items] objectAtIndex:3] setHidden:YES];  
    }
    return self;
}
@end

Any help would be apprciated.
Thanks in advance.

  • 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-06T03:15:40+00:00Added an answer on June 6, 2026 at 3:15 am

    I’m thinking the easier (probably not best) way to do this is by having the TabBar controller not be the initial view controller and creating two tab bar controllers. From your initial view you can decide with tab bar controller you will show. You can also have the two tab bar controllers linked to the same tabs/viewcontrollers (the ones that are repeated between them).

    In the initial view controller you add some code to know which segue you will perform and voila.

    Something like this:
    enter image description here

    I am looking into a code solution to this though (seems interesting!). Will update if I find anything.

    EDIT:
    Here’s the coded solution. (I am using storyboards but I am sure you can translate the code to work with nib files).

    The first thing to do is create an instance of the storyboard:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    

    Then instantiate the tabbarcontroller:

    UITabBarController *myTab = [storyboard instantiateViewControllerWithIdentifier:@"tabBar"];
    

    Then instantiate the new view controller you want to add to the tabbar:

    UIViewController *newVC = [storyboard instantiateViewControllerWithIdentifier:@"newView"];
    

    This is the interesting part, you put all the view controller/tabs into an array and then add or remove views from that array. Then you set the view controllers of the tabbarcontroller to the modified array (I add one viewController and remove another).

    NSMutableArray* controllers = [myTab.viewControllers mutableCopy];
    [controllers insertObject:newVC atIndex:0];
    [controllers removeObjectAtIndex:2];
    [myTab setViewControllers:controllers];
    

    Then you can just push your tab bar controller like this:

    [self.navigationController pushViewController:myTab animated:YES];
    

    Here I am using storyboards and ARC, you can modify it for nibs and release the array if you’re not using ARC. This was fun to write! hope it helps! cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to modify an app that currently has a UITabBarController as its initial
I have set my app's initial view with storyboard to the main one. I
My configuration: app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.cookieParser()); app.use(express.session({ secret:
In WP7 silverlight app, i wanted to use a storyboard animation on a particular
I am new to iPhone app. I was told not to use Xcode storyboard
I am not able to use SetTop property Canvas in Silverlight App. Following is
I have a storyboard based app with a navigation controller as the initial view
Almost every Express app I see has an app.use statement for middleware but I
So I have an app where I use for the UI a storyboard with
I want my navbars to use black transparent appearance. In my non-storyboard apps, i

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.