xcode 如何在Xcode的storyboard中显示状态栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42130743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:46:42  来源:igfitidea点击:

How to show status bar in storyboard of Xcode

iosiphonexcodestatus

提问by Joe Jordan

I'm trying to develop an app that has a navigation controller at the top. When viewing the app on the storyboard as an iPhone 7 Plus, the status bar is visible, and the layout is correct. When viewing as any other device, the status bar is missing, and the layout is off by 20px. I also get a "misplaced view" warning.

我正在尝试开发一个顶部有导航控制器的应用程序。作为iPhone 7 Plus在storyboard上查看app时,状态栏可见,布局正确。当以任何其他设备查看时,状态栏丢失,并且布局关闭 20 像素。我还收到“错位视图”警告。

I believe this has to do with the issue working while developing on my work computer, but then when I switch to my laptop, the Misplaced View errors start happening.

我相信这与在我的工作计算机上开发时出现的问题有关,但是当我切换到我的笔记本电脑时,Misplaced View 错误开始发生。

When running the app, the app works fine and looks as it should regardless of the device, but with everything off like this, it's hard to develop.

运行该应用程序时,该应用程序运行良好,无论使用何种设备,该应用程序都可以正常运行,但如果一切都这样关闭,就很难开发。

Did I change some default setting on my laptop to not show the status bar on some views in the storyboard view? Thanks for any help!

我是否更改了笔记本电脑上的某些默认设置,以便在情节提要视图中的某些视图上不显示状态栏?谢谢你的帮助!

iPhone 7 example showing no status bar in storyboard view, as well as incorrect placement of cells / views / images

iPhone 7 示例显示故事板视图中没有状态栏,以及单元格/视图/图像的位置不正确

EDIT:

编辑:

Update: At work (different Mac running Xcode with the same project files, the status bar shows on every preview (meaning no misplaced views). It's got to be something with my Xcode settings at home. Any ideas?

更新:在工作中(使用相同的项目文件运行 Xcode 的不同 Mac,状态栏显示在每个预览中(意味着没有错位的视图)。 它必须与我在家中的 Xcode 设置有关。有任何想法吗?

回答by Nirmalsinh

You need to change the value of "Status Bar"value and its visible into storyboard.enter image description here

您需要更改“状态栏”值的值及其在故事板中的可见性。在此处输入图片说明

回答by Misha

This is nit the issue with your VC but is with NavigationController, so select your NavigationVC and check mark the option underTopBars,

这不是您的 VC 的问题,但与 NavigationController 相关,因此请选择您的 NavigationVC 并选中 TopBars 下的选项,

NavigationController attribute inspector

NavigationController 属性检查器

回答by Ram

you can do it as

你可以这样做

override var prefersStatusBarHidden: Bool {
    return false
}

回答by Joe Jordan

Uninstalling and reinstalling Xcode on the mac with the issue seemed to solve the problem. I'm sure it's a bug.

在有问题的 mac 上卸载并重新安装 Xcode 似乎解决了问题。我确定这是一个错误。