I manually added UITabbarController in storyboard which is not root view controller. I added tabbar items to it and set segue relationships. I also set image and title of each tabbar item in code when the first view controller of UITabbarController is about to be presented but no matter what I do only the first item's image is visible. Other items images become visible only when they are tapped and their views are actually loaded. Any inputs how to fix it ?
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([segue.identifier isEqualToString:@"AfterLogin"]) {
UITabBarController *tabBarController = [segue destinationViewController];
NSArray *tabBarItems = tabBarController.tabBar.items;
UITabBarItem *item1 = tabBarItems[0];
UITabBarItem *item2 = tabBarItems[1];
UITabBarItem *item3 = tabBarItems[2];
UITabBarItem *item4 = tabBarItems[3];
[item1 setImage:[[UIImage imageNamed:@"image1_static"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item1 setSelectedImage:[[UIImage imageNamed:@"image1_active"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
item1 = @"";
item1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[item2 setImage:[[UIImage imageNamed:@"image2_static"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item2 setSelectedImage:[[UIImage imageNamed:@"image1_active"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
item2.title = @"";
item2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[item3 setImage:[[UIImage imageNamed:@"image3_static"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item3 setSelectedImage:[[UIImage imageNamed:@"image3_active"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
item3.title = @"";
item3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[item4 setImage:[[UIImage imageNamed:@"image4_static"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item4 setSelectedImage:[[UIImage imageNamed:@"image4_active"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
item4.title = @"";
item4.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
}
}