0

There is something with my ViewControllers' hierarchy that I don't get. Please take a look at my Storyboard:

enter image description here

What I'm trying to do, is programmatically setting the TabBarItem image associated with the NavigationController in the center of the Bottom Row. I want to do that with a button on the ViewController at Bottom Right.

I tried several things, like

self.navigationController.tabBarItem.image = someValidImage;

and

UITabBarItem *myIcon =[self.navigationController.tabBarController.tabBar.items objectAtIndex:2];
    myIcon.image = someValidImage;

but to no avail.

I'm sure it is something obvious, but I'm staring at this quite a while now. Could any of you help me out here?

Sjakelien
  • 2,255
  • 3
  • 25
  • 43

1 Answers1

1

Please try this here we set two types of image one for selected-state other one for unselected state hope this will help you!!..

here "xyz" will be your image name.

[[tabBarController_obj.viewControllers objectAtIndex:0] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"xyz.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"xyz.png"]];

try this for all tabs in ur case , I think u have to do three time.

Pawan Rai
  • 3,434
  • 4
  • 32
  • 42
user3306145
  • 76
  • 2
  • 12
  • Oh..my..dear..god! That must be the problem. Thank you so much! Let me try. I will reward you. – Sjakelien May 04 '16 at 15:19
  • That was it; your recommendation put an end to hours of misery. There is a more detailed (and less deprecated) explanation here: http://stackoverflow.com/questions/18894985/uitabbar-not-showing-selected-item-images-in-ios-7 – Sjakelien May 04 '16 at 15:36