Trying to hide iPhone status bar

I have a scroll with UIImage on top of the UIImage has its own view controller class and the scroll view is on the main root controller. I added the hide status bar method to the root controller, but when I run the program, the status bar disappears, but leaves empty space, and the view does not grow above the white space of the status bar. I'm tired of other methods, but I still get the same empty space. I also tried to enable vertical scrolling, and it looks like the status bar is on top of all my views, when I look up it continues to grow in the status bar.

What could be the reason for this?

+4
source share
3 answers

You just hid the status bar, it looks like the other components did not automatically expand to capture this space. Make sure that all the components of the primary root controller have the โ€œauto-split subheadingsโ€ feature enabled.

If this does not help, you can try moving and resizing your view in code. Sort of:

CGRect frame = self.view.frame; frame.origin.y -= statusBar.height; frame.size.height += statusBar.height; self.view.frame = frame; 
+7
source

I had the same problem that I was able to fix it by adding a call,

 // Where self == Your View Controller with the status bar hidden [self setWantsFullScreenLayout:YES]; 

Then I put this in my init method from the View Viewer, where the status bar is hidden. Then I added the following code to the view by loading or loading the view method.

 if ([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden:withAnimation:)]) { [[UIApplication sharedApplication] setStatusBarHidden:hide withAnimation:NO]; } else { // Deprecated in iOS 3.2+. id sharedApp = [UIApplication sharedApplication]; // Get around deprecation warnings. [sharedApp setStatusBarHidden:hide animated:NO]; } 

This will allow you to have a view controller with and without a status bar. For example, a photo application does this.

+2
source

A simple solution for a useful solution to JOMs with a dynamic height statusBar (no one should rely on a status bar equal to 20px, as indicated in the comment):

 // fix frame CGRect frame = window.frame; if( ! [UIApplication sharedApplication].statusBarHidden ) { int statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height; frame.origin.y += statusBarHeight; frame.size.height -= statusBarHeight; } self.view.frame = frame; 

btw: in my case, I needed to recount the frame and adapt it to the visible status bar.

0
source

All Articles