iPhone 5 TabBar not functioning in proper position

主宰稳场 提交于 2019-12-29 06:41:05

问题


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.


回答1:


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.




回答2:


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

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.




回答3:


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]];    
}


来源:https://stackoverflow.com/questions/12569189/iphone-5-tabbar-not-functioning-in-proper-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!