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

  • Home
  • SEARCH
  • 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 8461481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:53:31+00:00 2026-06-10T13:53:31+00:00

I have a tab bar controller and a bunch of the same tabs. Each

  • 0

I have a tab bar controller and a bunch of the same tabs. Each tab only differs in functionality, but the UI’s are all the same. In the storyboard I designed the flow and UI of one tab and set it base class. Then when I create the tabs I tried typecasting them before adding them to the tab bar but it didn’t work.

In the storyboard the View Controller indentified “TabView” has the custom class “TabColor”

TabRed *red = (TabRed *)[storyboard instantiateViewControllerWithIdentifier:@"TabView"];
TabBlue *blue = (TabBlue *)[storyboard instantiateViewControllerWithIdentifier:@"TabView"];

However the loadView method in TabColor gets called, not the TabRed/TabBlue.

Also if I nslog it the result is a TabColor object:

NSLog(@"%@", red)

Expected: TabRed

Actual: TabColor

  • 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-10T13:53:32+00:00Added an answer on June 10, 2026 at 1:53 pm

    tl;dr:

    Storyboards and xibs contain collections of serialized objects. Specifying a class in a storyboard means you will get an instance of that class when you load the storyboard. A way to get the behavior you’re looking for would be to use the delegation pattern common in cocoa/cocoa-touch.

    Long Version

    Storyboards, and similarly xib/nib files, are actually sets of encoded objects when you get down to it. When you specify a certain view is a UICustomColorViewController in the storyboard, that object is represented as a serialized copy of that an instance of that class. When the storyboard is then loaded and instantiateViewControllerWithIdentifier: gets called, an instance of the class specified in the storyboard will be created and returned to you. At this point you’re stuck with the object you were given, but you’re not out of luck.

    Since it looks like you’re wanting to do different things you could architect your view controller such that that functionality is handled by a different class using delegation.

    Create a protocol to specify the functionality you’d like to be different between the two view controllers.

    @protocol ThingDoerProtocol <NSObject>
        -(void) doThing;
    @end
    

    Add a delegate property to your viewcontroller:

    @interface TabColor
    ...
    @property (strong, nonatomic) thingDoerDelegate;
    

    And then have your new objects implement the protocol and do the thing you want them to.

    @implementation RedTabDoer
        -(void) doThing {
             NSLog(@"RedTab");
        }
    @end
    
    @implementation BlueTabDoer
        -(void) doThing {
             NSLog(@"BlueTab");
        }
    @end
    

    Then create and hook up those objects when you load the storyboard.

    TabColor *red = [storyboard instantiateViewControllerWithIdentifier:@"TabView"];
    red.thingDoerDelegate = [[RedTabDoer new] autorelease];
    
    TabColor *blue = [storyboard instantiateViewControllerWithIdentifier:@"TabView"];
    blue.thingDoerDelegate = [[BlueTabDoer new] autorelease];
    

    This should then allow you to customize the functionality of the view controller by changing the type of object that is assigned to the controllers delegate slot.

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

Sidebar

Related Questions

I have a tab bar controller with different view controllers all using the same
I have a tab bar controller with two tabs: tabBar1View with a button named
I have a tab bar controller with 5 different items, each representing different views.
Here's the setup: I have a tab bar controller with two tabs. There is
i have a tab bar controller in my storyboard. I have added a third
I have a tab bar controller with three tabs. Tab number two has a
I have a tab-Bar Controller + UINavigation Controller app. In tabs 1,2,3 I have
I have a tab bar controller with 3 tabs. In one of the tabs,
I have setup tab bar controller using interface builder, and each tab bar item
I have a tab bar controller and each tab consist of a navigation controller.

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.