1

I have this problem. I have a tabbar created in appDelegate:

RootViewController *controller = [[RootViewController alloc] initWithNibName:@"RootView" bundle:nil];
UINavigationController *rootNavigationController = [[UINavigationController alloc] initWithRootViewController:controller];

[other controllers initialized...]

self.tabController = [[UITabBarController alloc] init];
self.tabController.viewControllers = [NSArray arrayWithObjects:rootNavigationController,secondController,thirdController, nil];

Now when in RootViewController I try to assign an image to the tabBar:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    self.tabBarItem.image = [UIImage imageNamed:@"tabRoot.png"];
    self.tabBarItem.title = @"Root";
} 

But nothing is displayed, why? The strange thing is that if I do the same thing but without the navigationController, the image is correctly displayed.

Anna565
  • 735
  • 2
  • 10
  • 21

1 Answers1

0

Just use the below code

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabRoot.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabRoot.png"]];
manujmv
  • 6,450
  • 1
  • 22
  • 35