41

I want the status bar to be displayed in both orientations in iOS 8; it's being displayed properly in iOS 7.

navigationController.isNavigationBarHidden returns NO.

Why is iOS 8 doing this?

3
  • 1
    New feature in iOS8. Maybe only for the beta. Try with Setting.app, you'll see the same behaviour.
    – Larme
    Jun 20, 2014 at 16:05
  • 2
    Have a look imgur.com/a/JGT4a
    – Jageen
    Jun 25, 2014 at 12:20
  • 1
    Right now iOS 8 is beta version. Can be fixed in official release i.e in Sep, same thing faced when they have released iOS 7.
    – Ganesh G
    Jun 26, 2014 at 18:17

10 Answers 10

60

Try this

Add below code in didRotateFromInterfaceOrientation

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

EDIT
NO NEED TO WRITE CODE IN ALL VIEW CONTROLLER
Set View controller-based status bar appearance to NO in plist and add below code in root view controller's viewDidLoad

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

Demo project
https://www.dropbox.com/s/uumneidk4wom5md/demoStatusBar.zip?dl=0

6
  • we will have to write this code in every view controller, right? Oct 1, 2014 at 21:06
  • 1
    just try to code in once first root view controller, may help
    – Jageen
    Oct 2, 2014 at 5:27
  • 4
    This appears to be the best solution, with one minor suggested change i.e. use application:FinishLaunchingWithOptions: to force the status bar hidden state.
    – Mustafa
    Oct 23, 2014 at 7:28
  • 1
    Will it work with trait collection did change also? Really? With iOS 9?;) please confirm this... Jun 30, 2016 at 17:55
  • 2
    It is deprecated since iOS 9. Jul 1, 2016 at 6:37
49

To display status bar in landscape mode in ios 8, try following method

- (BOOL)prefersStatusBarHidden {
    return NO;
}

Swift version

override func prefersStatusBarHidden() -> Bool {
    return false
}

Swift 3, Xcode 8, iOS 10, /* ViewController.swift */

override var prefersStatusBarHidden: Bool {
        return false
    }
2
  • For Swift : override func prefersStatusBarHidden() -> Bool { return false; }
    – xevser
    Jan 28, 2016 at 10:48
  • It works only if you has set View controller-based status bar appearance in your plist file to YES. Jul 25, 2018 at 11:19
9

Jageen's solution is probably the best, with just one minor change i.e. instead of using viewDidLoad, it's better to use application:didFinishLaunchingWithOptions:.

It's basically a two step process:

1). Set "View controller-based status bar appearance" to NO, in your project's Info.plist file.

2). Force the status bar hidden status to NO, in application:didFinishLaunchingWithOptions:, using the following code:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

And, voila!

Note: It's important to use both the setStatusBarHidden:withAnimation statements above, to force the status bar hidden state.

1
  • 3
    A note: You don't need to call [UIApplication sharedApplication] in application:didFinishLaunchingWithOptions:, because there is a method argument application. Thus, just call [application setStatusBarHidden:...]. Feb 1, 2015 at 14:20
6

It's not an issue but a feature of an iOS 8. The status bar will be hidden in landscape mode in iOS 8, even Apple's applications also having same behaviour.

5

I had the same issue! Fixed by addicting this to viewDidLoad

  [self setNeedsStatusBarAppearanceUpdate];

And this to implementation itself

-(BOOL)prefersStatusBarHidden{
    return NO;
}
1
  • we will have to write this code in every view controller, right? Oct 1, 2014 at 21:07
4

They are keeping us gainfully employed by giving us more work.

or...

They've made other changes which cause bits to take up more space than they used to. With iOS 7 and the advent of things like the "Top Layout Bar Guide", the easy availability of the status bar in the swipe down screen, reclaiming the status bar space to be usable and other little hints many people predicted the status bar might be getting phased out as a standard part of the UI.

There is also quite a bit of buzz about new device sizes due to the changes they've made in iOS 8 trying to make it easier to code for a bunch of different sizes.

It's pure speculation, but I don't think they landscape status bar will return in iOS 8.

0
3

Swift 3

override func viewDidLoad() {
        super.viewDidLoad()
        UIApplication.shared.setStatusBarHidden(true, with: .none)
        UIApplication.shared.setStatusBarHidden(false, with: .none)
///
    }

and add inside Info.plist this:

UIViewControllerBasedStatusBarAppearance boolean value NO

1

Swift 3 (As of June 2, 2017)

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear()
    self.setNeedsStatusBarAppearanceUpdate()
}

override var prefersStatusBarHidden : Bool {
    return false
}
0

We fixed it by following the above steps and making sure that landscape left and right are both enabled.

Under Project/Target/Deployment Info

enter image description here

-2

We solved this by forcing an orientation change unseen by the user. In the first view controller that loads, add:

- (void)viewWillAppear:(BOOL)animated
{
    NSNumber *orientationLeft = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
    NSNumber *orientationRight = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
    [[UIDevice currentDevice] setValue:orientationLeft forKey:@"orientation"];
    [[UIDevice currentDevice] setValue:orientationRight forKey:@"orientation"];
}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.