0

I have created a UITabBarcontroller programatically as follows:

UITabBarController *tbc = [[UITabBarController alloc] init];   
[tbc setViewControllers:[NSArray arrayWithObjects:vc1,vc2,vc3,vc4,vc5,nil]];

which works ok. For each of the UIViewControllers, i want to set their tabbaritem.image to a specified image so i do this:

UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTitle:@"Search" image:
    [UIImage imageNamed:@"tab_bar_search_50_50.png"] tag:0];
vc1.tabBarItem = tbi1;

and i have also tried

vc1.tabBarItem.image = [UIImage imageNamed:@"tab_bar_search_50_50.png"];

and

 UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTitle:@"Search" image:
      [UIImage imageNamed:@"tab_bar_search_50_50.png"] selectedImage:
      [UIImage imageNamed:@"tab_bar_search_50_50.png"]];

The image size is 50x50 because according to apple-> https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1

a tabbar icon of size "About 50 x 50 (maximum: 96 x 64) is ok". Yet when i run this in both the simulator and on a device (both retina screens) the image is way too large and hangs over the top of the the tab bar.

Ive even tried adding @2x as a suffix to the file name which doesnt work, but i thought since the app is building only for ios7 that these were no longer needed?

Im guessing the problem is either a bug in iOS7 or the issue lies with the image size, but i read in the documentation that if the image is too big it will be clipped to a certain bound?

Tyler Durden
  • 575
  • 7
  • 23

1 Answers1

0

I believe i have solved my problem. The problem was that when i added the @2x suffix, i also included this in the naming of the UIImage:

[UIImage imageNamed @"image@2x.png"];

But this needs to be:

[UIImage imageNamed @"image.png"];
Tyler Durden
  • 575
  • 7
  • 23
  • Tyler Durden you mean to say image named should not have suffix @2x but what should be size of image for retina or non-retina. – Arpi Jul 15 '14 at 13:10