angrysword
angrysword

Reputation: 120

Hiding/Showing Status Bar

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

Upvotes: 5

Views: 2567

Answers (2)

Adam Waite
Adam Waite

Reputation: 18845

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.

Upvotes: 1

adurdin
adurdin

Reputation: 1386

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

Upvotes: 11

Related Questions