Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding/Showing Status Bar

Tags:

iphone

I'm developing an iPhone app that switches from a table view to a landscape fullscreen view (similar to the YouTube app). When it does so, I want to hide the status bar, then display it again when switching back to the table view. I'm using setStatusBarHidden but that just seems to hide the status bar wihout enlarging the screen area; there's still a blank bar where the status bar was. If set the hidden status bar property in Info.plist then I get the enlarged screen area but when the status bar displays it overlays the view.

How do I hide the status bar in such a way that the full screen is available to my view when it's hidden and only the screen under the status bar when it's displayed?

TIA.

Craig

PS: I copy/edit this question from app discussion. do not find good solution http://discussions.apple.com/thread.jspa?threadID=1580662&start=15&tstart=0

like image 323
angrysword Avatar asked Sep 15 '09 22:09

angrysword


People also ask

Can I hide my status bar?

Navigate to Device Restrictions to disable the status bar in Android devices. Restrict the Status Bar option to disable the status bar on the device. By default the Status Bar expansion option is restricted, which disables the notification bar.

What hide status bar means?

This lesson describes how to hide the status bar on different versions of Android. Hiding the status bar (and optionally, the navigation bar) lets the content use more of the display space, thereby providing a more immersive user experience. Figure 1 shows an app with a visible status bar: Figure 1. Visible status bar.


2 Answers

Your view controller should have wantsFullScreenLayout set to YES, as well as hiding the status bar: See UIViewController reference.

like image 56
adurdin Avatar answered Oct 31 '22 22:10

adurdin


If there is anyone looking for a solution where the above solution does not work (and there is still an annoying blue 20px gap at the top), try putting this in the viewWillAppear on the implementation file of the view controller that you would like the status bar to be hidden.

self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);

That literally took me 12 hours or so to fix, and that was the solution, so now i'm spreading the word in case anyone else has this annoying issue.

like image 44
Adam Waite Avatar answered Oct 31 '22 22:10

Adam Waite