iPhone 5 TabBar not functioning in proper position
Asked Answered
F

3

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.

Flied answered 24/9, 2012 at 16:32 Comment(4)
How is your window being created? See if this helps: anthonyprato.com/2012/09/20/…Animal
Yup that was it! Thanks!Flied
Helped me too! @aprato you answer this question -- I have no doubt it will be accepted!Policyholder
possible duplicate of UITabBarController does not respond on iPhone 5 simulator: 4-inch retina displayTarra
A
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.

Animal answered 27/9, 2012 at 17:40 Comment(0)
T
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.

Tarra answered 2/10, 2012 at 22:28 Comment(1)
Hi, Can we do it through coding?Jersey
P
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]];    
}
Parnas answered 24/9, 2012 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.