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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:30:06+00:00 2026-06-18T06:30:06+00:00

I am new to IOS development. I am facing an issue in dynamically setting

  • 0

I am new to IOS development. I am facing an issue in dynamically setting the images for Tabbar items. I have sub-classed the UITabbarItem .

@interface CustomTabBarItem : UITabBarItem
{
    UIImage *customHighlightedImage;
    UIImage *customStdImage;
}

@property (nonatomic, retain) UIImage *customHighlightedImage;
@property (nonatomic, retain) UIImage *customStdImage;

@end 

And added my tabbarcontroller to the window.

[_tabBarController setViewControllers: [[NSArray alloc] initWithObjects:1,2,3,4,nil] animated: YES];
_tabBarController.selectedIndex = 0;
_tabBarController.delegate = self;
_tabBarController.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"tabbarBackground.png"]];
[self.window addSubview:_tabBarController.view];
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];

My Tabbar controller is perfectly supporting all the orientation. But the problem is when i rotate the device, how can I set the images of tabbar items for the current orientation of the device. The frame gets automatically set for each tab but my images does not. I have four tabs in my application. I have searched a lot through the site but was not able to get the appropriate solution.

EDIT

This is the code that i am using for setting the images.

 tabBarItemBrowse=[[CustomTabBarItem alloc] init];
    tabBarItemBrowse.imageInsets=UIEdgeInsetsMake(6, 0, -6, 0);
    //    tabBarItemBrowse.customStdImage=[UIImage imageNamed:@"browser.png"];
    //    tabBarItemBrowse.customHighlightedImage=[UIImage imageNamed:@"browser_act.png"];
    if ( [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait ||  [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        tabBarItemBrowse.customStdImage=[UIImage imageNamed:@"browser.png"];
        tabBarItemBrowse.customHighlightedImage=[UIImage imageNamed:@"browser_act.png"];
    }

    else
    {
        tabBarItemBrowse.customStdImage=[UIImage imageNamed:@"browser568.png"];
        tabBarItemBrowse.customHighlightedImage=[UIImage imageNamed:@"browser_act568.png"];

    }
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    BrowseNav  = [[CustomNavigationControllerViewController alloc] initWithRootViewController:self.viewController];
    BrowseNav.tabBarItem = tabBarItemBrowse;
    BrowseNav.navigationBar.tintColor = [UIColor blackColor];
    BrowseNav.navigationBarHidden=YES;
    [tabBarItemBrowse release];
  • 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-18T06:30:07+00:00Added an answer on June 18, 2026 at 6:30 am

    Try this,
    Firstly ,you have to take two images i.e one for portrait mode and another for landscape mode . When your device change the orientation the -(void)willRotateToInterfaceOrientation method should be call. According to orientation you can set tabbar item image.

       -(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration: (NSTimeInterval)duration
    {
    if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) 
    {
    
      yourViewController.tabBarItem.image = [UIImage imageNamed:@"portrait.png"] ;
    }
     else
    
    {
    
      yourViewController.tabBarItem.image = [UIImage imageNamed:@"Landscape.png"] ;
    
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am quite new to iOS development and I'm facing a multithreading issue. I'm
I am new in ios development. I have to draw few graphs (Bar chart,
I am new to ios development. I am having a very serious issue now.
I am new in ios development. I have a UITextField. There I set a
I'm new to iOS development and am running into an issue with my header
new to iOS development, i have managed to create a basic app that can
I'm very new with iOS Development and I have just created one of my
I'm new to iOS development and I have being able to solve most of
Since I am new to iOS development I have a few Questions. Firstly I
I'm new at iOS development. I have two table views and a content detail

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.