Branch Branch - 4 months ago 20
Objective-C Question

Status bar won't go away on scaled up version of iOS 7 app

I have tried everything suggested here: Status bar won't disappear to no avail.

My iPhone version of my app has no status bar shown, but on my iPad, which runs the scaled up version of my iPhone version, there is a status bar that won't go away!

If it makes a difference, my app uses the devices camera for a majority of the app. If you need more info/code, don't hesitate to ask! My app is iOS 7 only, and I use Xcode 5. Also, I would like the status bar gone in the whole app.

Do not suggest UIViewControllerBasedStatusBar in the plist-- it does not work.




Related Articles

http://stackoverflow.com/a/18740897/294884

http://stackoverflow.com/a/21034908/294884

http://stackoverflow.com/a/20307841/294884

Answer

Note, for 2016 ...

All you do is

  • (1) click "Hide status bar" on the General settings, and

  • (2) UIStatusBarHidden - true in your plist.

(You must do both.)

(Give it another five or ten years and Apple will realize there should just be a button "no status bar". We live in hope.)


Historic answers...

The answer below is totally irrelevant unless you are, say, a technology historian. (Yes, Apple were this confused.)


For awhile the best thing to do was:

//2014, put this in your highest view controller. no longer works.
//override func prefersStatusBarHidden() -> Bool { return true }

Before that:


For iOS7/Xcode5. If you want (2012) no status bar in the whole app and always there are four points:

(historic - 1) make a category called UIViewController+HideStatusBar

@interface UIViewController (HideStatusBar)
@end

// most practical approach for no-statusbar in iOS7
@implementation UIViewController (HideStatusBar)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
-(BOOL)prefersStatusBarHidden
    { return YES; }
-(UIViewController *)childViewControllerForStatusBarHidden
    { return nil; }
#pragma clang diagnostic pop
@end

(historic - 2) in plist add

<key>UIStatusBarHidden~ipad</key>
<true/>

Which is needed if you're covering iPad.

(historic - 3) actually do not set "Status bar is initially hidden" to Yes in your plist.

(historic - 4) never alter UIViewControllerBasedStatusBarAppearance for any reason.

Historic note: many advanced programmers did not like using a category to override a call. If you were in this group the only real solution was a master subclass for VCs. Even older approaches to hiding the status bar can be found in truly ancient answers.