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?
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"]];
[[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"]];
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With