Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tabbar item image doesn't appear

I have an issue with the images of tabbar items. I set an image on each tabbar item but when i run the app, the only image that appears is that of the first tabbar item. Images of others tabbar items don't appear until i select one of these tabs. The code that i use to set an image on a tabbar item is the following:

[self.tabBarItem setImage:[UIImage imageNamed:@"multi30x30.png"]];

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"multi30x30.png"]
              withFinishedUnselectedImage:[UIImage imageNamed:@"multi30x30.png"]];

Can someone help me?

like image 345
hoya21 Avatar asked Nov 08 '13 08:11

hoya21


3 Answers

You can try this:

[[[self.tabBarController.viewControllers objectAtIndex:0] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"LocateIconActive.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"LocateIconInactive.png"]];

[[[self.tabBarController.viewControllers objectAtIndex:1] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"ProductsIconActive.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"ProductsIconInactive.png"]];

[[[self.tabBarController.viewControllers objectAtIndex:2] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"NextDeliveryIconActive.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"NextDeliveryIconInactive.png"]];
like image 65
Kumar Aditya Avatar answered Oct 20 '22 08:10

Kumar Aditya


[[tabBarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"blabla1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble1.png"]];
[[tabBarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"blabla2.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble2.png"]];
[[tabBarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"blabla3.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble3.png"]];
like image 41
Jignesh Chanchiya Avatar answered Oct 20 '22 06:10

Jignesh Chanchiya


use this code :--

- (BOOL)application:(UIApplication *)application
 didFinishLaunchingWithOptions:(NSDictionary 
  *)launchOptions
 {


UITabBarController *tabBarController 
= (UITabBarController 
 *)self.window.rootViewController;

UIImage *selectedImage0 = [UIImage
   imageNamed:@"tb_inorganic_selected"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"tb_inorganic_normal"];

UIImage *selectedImage1 = [UIImage imageNamed:@"tb_organic_selected"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"tb_organic_normal"];

UIImage *selectedImage2 = [UIImage imageNamed:@"tb_acid_selected"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"tb_acid_normal"];



UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
like image 1
Mohit Avatar answered Oct 20 '22 07:10

Mohit