On iOS8, displaying my app in landscape mode will hide the status bar but on iOS 7 the status bar is displayed on both orientations

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?

Answers


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


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
    }

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.


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

  [self setNeedsStatusBarAppearanceUpdate];

And this to implementation itself

-(BOOL)prefersStatusBarHidden{
    return NO;
}

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.


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.


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


Swift 3 (As of June 2, 2017)

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

override var prefersStatusBarHidden : Bool {
    return false
}

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

Under Project/Target/Deployment Info


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"];
}

Need Your Help

Deploy ASP.NET MVC on IIS 5.1 (Windows XP)

asp.net-mvc deployment iis-5

OK, deploying ASP.NET MVC seems to be painful. I want to deploy my ASP.NET MVC application on Windows XP (IIS 5.1), but can't seem to find how to do it. When I type the application name into the web

What is a Ruby equivalent for Python's "zip" builtin?

python ruby translation

Is there any Ruby equivalent for Python's builtin zip function? If not, what is a concise way of doing the same thing?