Search code examples
iosobjective-cuitabbarcontrolleruitabbaritem

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?


Solution

  • 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"]];