prefersStatsuBarHidden not called on iPhone X simulator

When running a bare-bones test project in Xcode 9 Beta 1 (consisting of basically nothing but a nav controller and a view controller) I have found different behavior related to prefersStatusBarHidden depending on whether or not I am running on the iPhone X simulator or not.


Specifically, when I launch with a UINavigationController as the root view controller and a single UIViewController on the stack, the view controller's prefersStatusBarHidden computed property is called (as expected) for pretty much every simulator just before the view controller appears. But it is *not* called when running the exact same code in the iPhone X simulator (and in fact the status bar is *not* hidden on that simulator).


To get the same behavior on the iPhone X simulator, I am forced to subclass UINavigationController and override childViewControllerForStatusBarHidden (returning viewController).


Is this supposed to happen?


(Note also that this behavior differs from Xcode 9 and iOS 11 GM -- prefersStatusBarHidden is checked on all simulators.

Replies

in my case, it was already ignoring the value in landscape in 11.0.x, it always hide the status bar in landscape despite the value of prefersStatusBarHidden. But I'm not using navigation controller

I have the same problem and have to move the code to subclass of UINavigation. Thanks!

In my case, the top most view controller is already a subclass of UITabBarController. And its prefersStatusBarHidden is not called either. Anybody knows a another work-around for this?


EDIT: found the solution. I needed to explicitly implement childViewControllerForStatusBarHidden in the top most view controller as well:


- (UIViewController *) childViewControllerForStatusBarHidden

{

return nil;

}

For anyone who's interested, I filed a bug and heard back from Apple that this is intended behavior on the iPhone X when the navigation controller's navigation bar is not hidden: "If you want to hide the status bar on iPhone X, you should also hide the navigation bar, otherwise you should leave both visible. This is the behavior that UINavigationController implements."