简体   繁体   English

导航栏隐藏状态栏

[英]Navigation Bar hiding status bar

Like the title says, I have a navigation bar that is hiding my status bar. 如标题所示,我有一个导航栏,它隐藏了我的状态栏。 I have been running my application on a simulator and recently started running it on a device, iPhone 4s iOS7, and noticed that the status bar is hidden or being hidden, only thing you can see is the green battery life. 我一直在模拟器上运行我的应用程序,最近开始在iPhone 4s iOS7设备上运行它,并注意到状态栏处于隐藏或隐藏状态,您唯一能看到的就是绿色电池寿命。 The reason that I think it is being hidden is that I have a search bar in one of my view controllers and when I'm using the search bar you can see the status bar, the cell provider, time, etc. 我认为它被隐藏的原因是,我的一个视图控制器中有一个搜索栏,当我使用搜索栏时,您可以看到状态栏,单元格提供者,时间等。

Things I've done to see if I didn't do it accidentally: 我已经做过的事情以查看是否不是偶然发生的:

Checked the Target-> Deployment Info ->Status Bar Style. It is in Default.

Checked each xib file to see if the status bar is set to none. All of them are at Default.

Searched the keyword "hidden" in all my .m files.

Anyone have any suggestions? 有人有什么建议吗? I've searched through here and only see posts about people actually wanting to hide it not fixing it. 我在这里搜索过,仅看到有关实际上想要隐藏它而不修复它的人的帖子。 If anyone has had something similar happen to them, I'm open to trying anything. 如果有人发生过类似的事情,我愿意尝试任何事情。

Answer: 回答:

I was using a navigation bar image and the sizes were different. 
I was using iOS6 bar size, 32x32, but now I am using 88x64 and 
that fixed it for iOS7. How do I check if phone is iOS6 or iOS7?

The status bar is not hidden. 状态栏未隐藏。 On iOS 7, the status bar is always visible and it overlaps your application in a way it did not on iOS 6 and earlier. 在iOS 7上,状态栏始终可见,并且以与iOS 6及更低版本上不同的方式与您的应用程序重叠。 This is the new "normal" behavior. 这是新的“正常”行为。 The status bar no longer has a background color. 状态栏不再具有背景色。 It is either black text on a clear background ( UIStatusBarStyleDefault ) or light text on a clear background ( UIStatusBarStyleLightContent ). 它是透明背景上的黑色文本( UIStatusBarStyleDefault )或透明背景上的浅色文本( UIStatusBarStyleLightContent )。

If you change the status bar appearance to Light Content you will be able to see your status bar on a dark background. 如果将状态栏外观更改为“浅色内容”,您将能够在深色背景上看到状态栏。

Status bar appearance is controlled along one of two mutually-exclusive basis paths: you can either set them programmatically in the traditional manner, or UIKit will update the appearance for you based on some new properties of UIViewController. 状态栏外观是通过两个互斥的基本路径之一控制的:您可以以传统方式通过编程方式设置它们,或者UIKit将基于UIViewController的一些新属性为您更新外观。 The latter option is on by default. 默认情况下,后一个选项处于启用状态。 Check your app's plist value for "ViewController-Based Status Bar Appearance" to see which one you're using. 检查应用程序的“基于ViewController的状态栏外观”的plist值,以查看使用的是哪个。 If you set this value to YES , every top-level view controller in your app (other than a standard UIKit container view controller) needs to override preferredStatusBarStyle , returning either the default or the light style. 如果将此值设置为YES ,则应用中的每个顶级视图控制器(标准UIKit容器视图控制器除外)都需要重写preferredStatusBarStyle ,以返回默认样式或浅色样式。 If you edit the plist value to NO , then you can manage the status bar appearance using the familiar UIApplication methods. 如果将plist值编辑为NO ,则可以使用熟悉的UIApplication方法管理状态栏的外观。

I know its knida too late but this approach solved my issue with the Status bar: 我知道它的knida为时已晚,但是这种方法通过状态栏解决了我的问题:

What I did was set the 我所做的是

   self.view.backgroundcolor=[UIcolor WhiteColor];

and then Created a subview within the main view with the same width and height as self.view and then modified its frame accordingly such as: 然后在主视图内创建一个宽度和高度与self.view相同的子视图,然后相应地修改其框架,例如:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    if(self.customView.frame.origin.y == 0) {
        CGRect viewBounds = [self.customView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.customView.frame = viewBounds;
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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