15

I am updating our app and I have added the new default image but my tab bar was not working on the iPhone 5. I did some research and created an if statement checking for the size of the display and then placing the tab bar in the proper location. The problem is that when the if statement hits the iPhone 5 screen size and places the tab bar in the right place, the buttons do not work... If I change the vertical location to a lesser value the buttons then work. Here is the code:

UITabBar *tabBar = self.tabBarController.tabBar;

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        tabBar.frame=CGRectMake(0,431,320,49);
    }
    if(result.height == 568)
    {
        tabBar.frame=CGRectMake(0,519,320,49);
    }
}

Now if I change the "519" vertical alignment to "450" the tab bar is higher up on the screen but the buttons do work. Any ideas -- it's driving me nuts! It's the last thing I need to get working for me to launch my update.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Mat
  • 223
  • 3
  • 9
  • 3
    How is your window being created? See if this helps: http://anthonyprato.com/2012/09/20/iphone-5-problem-with-touches-at-the-bottom-of-the-screen/ – Anthony Sep 25 '12 at 17:18
  • Yup that was it! Thanks! – Mat Sep 25 '12 at 23:02
  • Helped me too! @aprato you answer this question -- I have no doubt it will be accepted! – freespace Sep 26 '12 at 11:03
  • possible duplicate of [UITabBarController does not respond on iPhone 5 simulator: 4-inch retina display](http://stackoverflow.com/questions/12543567/uitabbarcontroller-does-not-respond-on-iphone-5-simulator-4-inch-retina-display) – nevan king Oct 02 '12 at 22:33

3 Answers3

17

If your window is being created in an older nib there is most likely a checkbox that needs to be checked on the windows attributes titled "full screen at launch"

More info here.

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
Anthony
  • 2,867
  • 1
  • 17
  • 17
13

Check the "Full Screen at Launch" option for your main window in Interface Builder.

enter image description here

If you want to do it without Interface Builder, add

window.frame = [UIScreen mainScreen].bounds;

at the start of your applicationDidFinishLaunching: or application:didFinishLaunchingWithOptions: in the app delegate.

nevan king
  • 112,709
  • 45
  • 203
  • 241
0

This happens due to screen height issue between iPhone 5 and iPhone 4. Add below snippet in AppDelegate file. This solved my problem.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    
}
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177