Display status bar on landscape orientation for iO

2019-03-28 09:53发布

问题:

Currently using XCode6 at the moment. Since this version of XCode only supports iPhone4 and above with OS version (7.0.3 onwards).

I have this application solely designed with a landscape orientation to all of the views in the storyboard. Testing the application using version 7.0.3 was fine, the status bar was still visible. It wasn't the same for version 8.0 wherein the status bar was hidden.

My question is how is it possible to display the status bar on my landscape oriented application that supports version 7.0.3 onwards. Thanks.

回答1:

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

- (BOOL)prefersStatusBarHidden {
    return NO;
}

Also what you can try is when the app goes landscape mode, write below line.

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


回答2:

  1. Make changes to the supported orientation in xcode so that it supports only landscape mode.
  2. Go to info.plist and add an entry and set "View controller-based status bar appearance" = NO
  3. Go to your AppDelegate.m and add[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];


回答3:

I'm not sure if this is the right answer. Yet this one works but there's a glitch on iPhone6/iPhone6Plus, it doesn't get displayed upon application start.

[application setStatusBarHidden: NO];


回答4:

From what I can tell, unless Apple have introduced a new API that I haven't found... The status bar is always hidden when the devices vertical size class is compact.

I haven't found a way around this yet but I don't think there is a way to get around it.. All of the system apps do the exact same thing.

Although, if you compile your app against the iOS 7.1 SDK you can still keep the status bar in landscape but thats not very useful if you want to adopt the new APIs etc.

Edit:

Maybe i'm wrong, the native Twitter app keeps the status bar when viewing a web page in landscape... Not sure how its being done though...