3

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

Pushparaj
  • 415
  • 8
  • 21

3 Answers3

1

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.

ares777
  • 3,590
  • 1
  • 22
  • 23
  • Yes have set the barStyle. But same is the case for iOS7. I'm using the `setFinishedSelectedImage:withFinishedUnselectedImage:` only for ios6 and other code is same. – Pushparaj Sep 23 '14 at 12:53
  • [[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor colorWithRed:(254/255.0) green:(196/255.0) blue:(36/255.0) alpha:1]]; //just in case :) – ares777 Sep 23 '14 at 12:54
  • I have used `translucent` to YES and set the `backgroundImage` of the tabbar for tint. – Pushparaj Sep 23 '14 at 13:01
  • Try to NSLog item.image content after didload , didappear. It is still there? – ares777 Sep 23 '14 at 13:05
  • I am thinking to check every tab bar element and see if it not set up to system type. – ares777 Sep 23 '14 at 13:07
  • logging the image object after the display. I am using custom tabbar so it's not set to system type. – Pushparaj Sep 23 '14 at 13:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/61758/discussion-between-user3344236-and-zala). – ares777 Sep 23 '14 at 13:34
0

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

Pushparaj
  • 415
  • 8
  • 21
0

You may use the following code:

UITabBarItem *maps = [[UITabBarItem alloc] initWithTitle:nil image:[[UIImage imageNamed:@"map_icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] tag:3];
[navMaps setTabBarItem:maps];
Adnan
  • 5,025
  • 5
  • 25
  • 44
  • 2
    While this code may solve the problem, it would be better if you add a brief explanation about the problem and how does your code solve it. A code-only answer won't likely be helpful to future visitors. – dic19 Oct 15 '14 at 12:02