隐藏 UIStatusBar 会在屏幕上留下空的蓝色条

发布于 2024-12-01 18:37:40 字数 260 浏览 0 评论 0原文

我有一个纵向 iPhone 应用程序,它有一个隐藏的导航栏,控制视图之间的流程。在一个视图中,我需要将视图旋转 90 度为横向,并且我想隐藏状态栏。

问题在于,虽然状态栏被正确隐藏,但它在状态栏所在的屏幕顶部留下了一个空的浅蓝色栏。我的视图实际上位于该栏下方,填满了屏幕。

我尝试过调整视图的大小,但它已经设置为屏幕的完整大小。看来这个蓝色条超出了我的视野。

难道是因为我把导航栏和状态栏都隐藏了?

任何帮助,非常感谢。

邓克

I have a portrait iPhone app, which a hidden navigation bar controlling the flow between views. In one view, I need to rotate the view 90 degrees to landscape, and I want to hide the status bar.

The problem is that whilst the status bar is correctly hidden, it leaves an empty light-blue bar across the top of the screen where the status bar was. My view actually sits under this bar, filling the screen.

I've tried playing with the size of the view, but its already set to the full size of the screen. It seems this blue bar is ABOVE my view.

Could it be because I have hidden both the navigation bar and the status bar?

Any help, much appreciated.

Dunc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风也等你 2024-12-08 18:37:40

如果您使用隐藏导航栏的 UINavigationController(UINavigationBar 本身不执行任何操作),那么您需要调整窗口中的导航控制器框架,而不是视图的框架导航控制器中的控制器视图。这是您的视图层次结构:

window (root view)
  - statusBar
  - navigation controller's view
    - view controller's view

当您隐藏状态栏时,请在视图控制器中尝试此操作:

[[[self navigationController] view] setFrame:[[UIScreen mainScreen] bounds]];

或者,如果您想使用窗口的框架:

[[[self navigationController] view] setFrame:[[[UIApplication sharedApplication] keyWindow] bounds]];

If you're using a UINavigationController with its navigation bar hidden (a UINavigationBar does nothing on its own), then you need to adjust the navigation controller's frame in the window, not the frame of your view controller's view in the navigation controller. Here's your view hierarchy:

window (root view)
  - statusBar
  - navigation controller's view
    - view controller's view

Try this in your view controller when you hide the status bar:

[[[self navigationController] view] setFrame:[[UIScreen mainScreen] bounds]];

Or, if you want to use the window's frame:

[[[self navigationController] view] setFrame:[[[UIApplication sharedApplication] keyWindow] bounds]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文