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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:38:56+00:00 2026-05-17T15:38:56+00:00

i created TAb bar programatically in this manner UITabBarController *tabBarController = [[UITabBarController alloc] init];

  • 0

i created TAb bar programatically in this manner

UITabBarController  *tabBarController = [[UITabBarController alloc] init];


    contacts *vc1 = [[contacts alloc]init];

    vc1.tabBarItem.image=[UIImage imageNamed:@"contacts.png"];

    search* vc2 = [[search alloc] init];

    vc2.tabBarItem.image=[UIImage imageNamed:@"search.png"];

    a1* vc3 = [[a1 alloc] init];

    a2 *vc4 = [[a2 alloc] init];

    a3 *vc5 = [[a3 alloc] init];


    NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2,vc3,vc4,vc5, nil];
    tabBarController.viewControllers = controllers;

    [self.view addSubview:detailNavCont];
    // Add the tab bar controller's current view as a subview of the window
    [self.view addSubview:tabBarController.view];

What i want to accomplish is, i want to assign images to tab bar, firstly i tried on first 2 tabs, is showing a blue block instead of image.
secondly, when we create tab bar through Interface builder, there are custom tab bar item, like, contacts, search, bookmark ,compose etc.

so, if i want to assign contacts or search image to my tab bar items,which looks like the one in IB, how can i do it??

regards

  • 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-17T15:38:56+00:00Added an answer on May 17, 2026 at 3:38 pm

    Try something like this

    tabBars = [[UITabBarController alloc] init];
    NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
    
    HomeTabViewController *ptr_homeTab;
    ptr_homeTab = [[HomeTabViewController alloc]initWithNibName:@"HomeTabViewController" bundle:nil];
    UINavigationController *homeNavBar=[[UINavigationController alloc]initWithRootViewController:ptr_homeTab];
    homeNavBar.tabBarItem.title=@"Home";
    homeNavBar.tabBarItem.image=[UIImage imageNamed:@"home.png"];
    [ptr_homeTab release];
    
    myHospitalviewController=[[MyHospitalViewController alloc]initWithNibName:@"MyHospitalViewController" bundle:nil];
    UINavigationController *myHospitalNavBar=[[UINavigationController alloc]initWithRootViewController:myHospitalviewController];
    myHospitalNavBar.title=@"My Hospital";
    myHospitalNavBar.tabBarItem.image=[UIImage imageNamed:@"myhospital.png"];
    [myHospitalviewController release];
    
    viewController = [[TreatMentiViewController alloc]initWithNibName:@"TreatMentiViewController" bundle:nil];
    UINavigationController *hospitalNavBar=[[UINavigationController alloc]initWithRootViewController:viewController];
    hospitalNavBar.tabBarItem.title=@"Hospital";
    hospitalNavBar.tabBarItem.image=[UIImage imageNamed:@"hospital.png"];
    [viewController release];
    
    PersonalMedicineViewController *ptr_PersonalMedicine = [[PersonalMedicineViewController alloc] initWithNibName:@"PersonalMedicineViewController" bundle:nil];
    UINavigationController *managerNavBar=[[UINavigationController alloc]initWithRootViewController:ptr_PersonalMedicine];
    managerNavBar.tabBarItem.title=@"Manager";
    managerNavBar.tabBarItem.image=[UIImage imageNamed:@"manager.png"];
    [ptr_PersonalMedicine release];
    
    [localViewControllersArray addObject:homeNavBar];
    [localViewControllersArray addObject:hospitalNavBar];
    [localViewControllersArray addObject:myHospitalNavBar];
    [localViewControllersArray addObject:managerNavBar];
    
    [homeNavBar release];
    [hospitalNavBar release];
    [myHospitalNavBar release];
    [managerNavBar release];
    
    tabBars.viewControllers = localViewControllersArray;
    tabBars.view.autoresizingMask==(UIViewAutoresizingFlexibleHeight);
    
    [localViewControllersArray release];
    
    [window addSubview:tabBars.view];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to this iphone development.I have created a tab bar application which
I created a Tab Bar Controller which has 5 tab bar items. I am
I created a tab bar application from the template and added a navigation controller
I have created an tab bar application having 3 tab. When I am launching
I have created a Tab Bar Application, removed the default FirstView and SecondView and
I have a Tab Bar Controller created in Interface Builder Within the Tab Bar
iOS includes setFinishedSelectedImage:withFinishedUnselectedImage: for customize the tab bar. I created a few textures with
I have created tab bar programmatically in the view controller. In my application, Initially
I have a tab bar that is created programmatically and I'm having difficulties initializing
My tab bar was created through the storyboard. I am trying to figure out

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.