开发者

Hiding UIStatusBar leaves empty blue bar across screen

开发者 https://www.devze.com 2023-03-30 21:19 出处:网络
I have a portrait iPhone app, wh开发者_如何学运维ich 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 s

I have a portrait iPhone app, wh开发者_如何学运维ich 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


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

精彩评论

暂无评论...
验证码 换一张
取 消