3
votes

I have a previously existing app(pre iOS8) that uses UITabbar with custom image. The tabbar is visible in iOS7 simulator and device, but it is not displaying in iOS8. What is causing this issue? I'm using image and selectedImage properties of UITabBarItem with UIImageRenderingModeAlwaysOriginal of images. Is the issue with the XCode 6 or iOS simulator(iPhone) or we can't use the custom images(only grayscale images are allowed!?) in tabbar anymore? reference for image property of tabbaritem

  • iOS7:

enter image description here

  • iOS8:

enter image description here

3

3 Answers

1
votes

Let's say you have an array of images in your project:

   NSArray *icons_low = [[NSArray alloc]init];
   icons_low =  [NSArray arrayWithObjects:@"first_tab_ic.png",  @"second_tab_ic.png", @"third_tab_ic.png", @"4th_tab_ic.png", nil];
   for(int i=0;i<icons_low.count;i++) {
          UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:i];
          NSString *img_name = [NSString stringWithFormat:@"%@", [icons_low objectAtIndex:i] ];
 /* deprecated -> comment such lines  
  [item setFinishedSelectedImage:[UIImage imageNamed:img_name] withFinishedUnselectedImage:
         [UIImage imageNamed:img_name]]; */
         item.image = [[UIImage imageNamed:img_name]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
         item.selectedImage = [[UIImage imageNamed:img_name]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    }

But I also suspect the fact your tabbar (check XIB) have setup something related to setBarStyle.

0
votes

Problem with my approach on initialising the tabbar items(in the method when login completes inside login screen itself). I having the login check logic inside the viewDidLoad of login screen and segueing to home screen if user logged in. But in viewWillAppear of the login I am resetting the tabbarItems.

In pre iOS 8 login screen is not displaying and I have the initialised tabbar in home screen. But in iOS 8 it displays the Login screen(for a while) even if I am segueing to home screen from viewDidLoad.

To solve the issue I have moved the tabbar items init code into home screen.enter image description here

0
votes

You may use the following code:

UITabBarItem *maps = [[UITabBarItem alloc] initWithTitle:nil image:[[UIImage imageNamed:@"map_icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] tag:3];
[navMaps setTabBarItem:maps];