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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:59:54+00:00 2026-05-25T10:59:54+00:00

I have a TabBarController and define two tabs in my code like: NSMutableArray *viewControllerArray

  • 0

I have a TabBarController and define two tabs in my code like:

NSMutableArray *viewControllerArray = [[NSMutableArray alloc]initWithCapacity:2];

DisplayMarketViewController *displayMarketViewController = [[DisplayMarketViewController alloc]init];     
[viewControllerArray addObject:displayMarketViewController];
[displayMarketViewController release];

DisplayDifferenceMarketViewController *displayDifferenceMarketViewController = [[DisplayDifferenceMarketViewController alloc]init];
[viewControllerArray addObject:displayDifferenceMarketViewController];
[displayDifferenceMarketViewController release];
myTabBarController.viewControllers = viewControllerArray;

in my DisplayMarketViewController.m

self.tabBarItem.title = @"Tab1";
UIImage *image = [UIImage imageNamed:@"1.png"];
self.tabBarItem.image =image;

and DisplayDifferenceMarketViewController.m

self.tabBarItem.title = @"Tab2";
UIImage *image = [UIImage imageNamed:@"2.png"];
self.tabBarItem.image =image;

but the Tab2 isn’t show until the tab item is tapped. How do I solve this problem?

  • 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-05-25T10:59:55+00:00Added an answer on May 25, 2026 at 10:59 am

    Your DisplayDifferenceMarketViewController isn’t initialized until it’s accessed by tapping the tab bar. Therefore, the code to change the tab title isn’t executed until you access it.

    Simply put all of your tabBar related code outside the view controllers in the tab bar, with the rest of your tab bar code like so:

    NSMutableArray *viewControllerArray = [[NSMutableArray alloc]initWithCapacity:2];
    
    DisplayMarketViewController *displayMarketViewController = [[DisplayMarketViewController alloc]init];     
    [viewControllerArray addObject:displayMarketViewController];
    [displayMarketViewController release];
    
    DisplayDifferenceMarketViewController *displayDifferenceMarketViewController = [[DisplayDifferenceMarketViewController alloc]init];
    [viewControllerArray addObject:displayDifferenceMarketViewController];
    [displayDifferenceMarketViewController release];
    myTabBarController.viewControllers = viewControllerArray;
    
    [viewControllerArray objectAtIndex:0].tabBarItem.title = @"Tab1";
    UIImage *image = [UIImage imageNamed:@"1.png"];
    [viewControllerArray objectAtIndex:0].tabBarItem.image =image;
    
    [viewControllerArray objectAtIndex:1].tabBarItem.title = @"Tab2";
    UIImage *image = [UIImage imageNamed:@"2.png"];
    [viewControllerArray objectAtIndex:1].tabBarItem.image =image;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
I have an application where I have a TabBarController with 4 tabs init, When
I'm using a TabBarController with a few Tabs and I have memory problems when
Okay, what I currently have is a TabBarController with five tabs. Each of these
I have an application that has a UITabBarController with two tabs, each having its
I have a TabbarController with 3 tabs with each tab representing a navigation Controller.
I have a TabBarController, which consists of three tabs, one of which is the
I have an application with a TabBarController containig two TabBars with a NavigationController. In
I am using a view Controller which have contains tabbarcontroller(4 tabs). each tabbar have
I'm trying to build an app where I have a TabBarController with 4 entries.

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.