简体   繁体   中英

iOS7 Status Bar over Navigation Bar

I'm testing my application with iOS7 and I have an issue with status bar. Basically the status bar appear over navigation bar like the image below:

iOS7状态栏问题

I try to call in my viewDidLoad

 self.edgesForExtendedLayout = UIRectEdgeNone;
 self.automaticallyAdjustsScrollViewInsets = YES;

without success.

I have also added to the info.plist file UIViewControllerBasedStatusBarAppearance with no luck.

The main problem is that the application must be compatible with iOS6 and iOS7 and currently on iOS7 the view shifted 20px from the top.

edgesForExtendedLayout and automaticallyAdjustsScrollViewInsets are just standards for how parent view controllers lay out / manage the view. It looks like you're using a UINavigationBar, but not a UINavigationController, which means these properties won't do anything unless you code them to.

You can switch to use a UINavigationController, or you can programmatically change the height of your UINavigationBar from 44 to 64 on iOS 7.

Add an outlet to the UINavigationBar.

float currentVersion = 7.0;

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
    // iOS 7
    self.navBar.frame = CGRectMake(self.navBar.frame.origin.x, self.navBar.frame.origin.y, self.navBar.frame.size.width, 64);
}

You can also hide the status bar, this might be a better approach on these views to get more screen real estate.

I answered that here:

Position of navigation bar for modal view - iOS7

这是iOS 7带来的最大问题,有很多解决方案可以解决这个问题,但在我看来,最好的解决方法是删除导航栏并将视图控制器嵌入导航控制器中,方法是转到编辑器>嵌入式导航控制器。

Add constraints top space to top layout guide

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM