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.

4

3 Answers 3

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.

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.

1
  • 1
    Hi, Can we do it through coding? Oct 12, 2012 at 7:31
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]];    
}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.