iOS 7.1 issue - Tabbar icon image is automatically resize when touch and drag on that tab button

27,256

Solution 1

This problem was resolved by setting the imageInsets of the tabBarItem as others have mentioned. You can do this in code or you can do it in Interface Builder, it doesn't matter.

The important point is to have the top inset BE EQUAL to the bottom inset.

Solution 2

I had the same problem on iOS 7.1 when trying to set the Image insets by code like:

[self.tabBarItem setImageInsets:UIEdgeInsetsMake(5, 0, -5, 0)];

So I solved it using directly the Bar Item Size on my Storyboard.

Bar Item Size menu

Take in count that for this to work you should be assigning the image of you TabBarItem in the following way

UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *myItem = [tabBar.items objectAtIndex:0];

[homeItem setFinishedSelectedImage:[UIImage imageNamed:@"A.png"]
       withFinishedUnselectedImage:[UIImage imageNamed:@"B.png"]];

instead of this way

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"A.png"]
              withFinishedUnselectedImage:[UIImage imageNamed:@"B.png"]];

Update

To access the Bar Item Size select directly the 'Item' element under the Scene of any of your Tab Bar Controller's child. (Image1)

enter image description here

Solution 3

my problem is similar, the tabbar icon changed it position in 7.1 update, this problem is really annoying, and I did a quick solution because I have to approve the app. Was this:

tab bar soluction in nib

Ok I not sure that is the best solution, but for me works.

Solution 4

Same problem here. Also after update to iOS 7.1 and xcode 5.1 My solution: The tab bar item size was set at 4 for Bottom.(in Size inspector) I changed it to 0 like all the others and the problem was gone.

Solution 5

My answer is based on others posted here - setting to 0 all ImageInsets in tab bar items:

for (UITabBarItem* item in self.tabBar.items)
{
    [item setImageInsets: UIEdgeInsetsMake(0, 0, 0, 0)];
}
Share:
27,256

Related videos on Youtube

SaintTail
Author by

SaintTail

Updated on July 09, 2022

Comments

  • SaintTail
    SaintTail almost 2 years

    I have this code

    [tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"tab_pressed_home_icon"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_home_icon"]];
    
    tabBarItem1.imageInsets = UIEdgeInsetsMake(8, 0, -2, 0);
    

    which set an icon on the tab bar.

    everything work fines so far until last night that i update Xcode 5.1

    and run the app on ios7.1 simulator.

    here is the app enter image description here

    now when i tap the tab bar the icon image size is decrease an when i release the finger image is back to normal. But if i tap the icon and drag it the image is look like this (scale down).

    like this enter image description here

    how can this happen? is there anyway to solve this?

    Thanks.

    • yuhua
      yuhua about 10 years
      i got the same problem, and found it caused by setting image insets with UITabBarItem. this is the code: [barItem setImageInsets:UIEdgeInsetsMake(15, 7.5, 0, 7.5)];everything goes well while comment it.
    • TheTiger
      TheTiger about 10 years
      Yes it is creating the problem in IOS 7.1. And I think tabbar height has been changed to 44 now.
    • the_critic
      the_critic about 10 years
      Same thing here. This bug is naaasty! The strange thing is, it only happens for one of my tab bar icons and I don't even use storyboards...
    • Roma
      Roma about 10 years
      have you tried run it on device? I got similar problem with simple uiimageView - it looks OK on device but streched on the simulator.
    • iEinstein
      iEinstein almost 10 years
      Has anyone find the solution of the problem?
    • iXcoder
      iXcoder about 6 years
      same issue , it should ios bug
  • Ahmad Al-Attal
    Ahmad Al-Attal about 10 years
    i think i made a mistake in here, as per to your question your problem is with the selected image so in the last line of code replace "setImage:" with "setSelectedImage:".
  • wrightak
    wrightak about 10 years
    setFinishedSelectedImage is deprecated in iOS 7.0
  • daspianist
    daspianist almost 10 years
    This solved the problem. Basically they have to cancel each other out: item.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
  • clocksmith
    clocksmith almost 10 years
    The top inset does not have to be equal to the bottom inset. The sum of the top and bottom should be equal to the sum of the left and right (if you don't want to stretch or shrink).
  • John
    John about 9 years
    How does one get to the bar item size area of story board?
  • CoderPug
    CoderPug about 9 years
    Directly select on of your Tab Bar Controller's child they have an 'item' which represents the Bar Item. I will upload an image and update my answer
  • Charlton Provatas
    Charlton Provatas over 7 years
    @clocksmith mine are both equal and i still have this issue