6

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.

David B
  • 3,269
  • 12
  • 48
  • 80
  • 1
    The reason this happens is that `UIViewController`’s implementation of `prefersStatusBarHidden` returns `YES` when its trait collection’s horizontal size class is compact. This is not documented. – Douglas Hill Sep 01 '15 at 18:21

4 Answers4

14

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];
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • Correct me if I'm wrong. I will need to add the code in every UIViewController sub-classes? – David B Sep 25 '14 at 11:06
  • I will say **yes..**, but try with once and let me know whether its working or not... – Fahim Parkar Sep 25 '14 at 11:10
  • I only placed the first code block on my custom view controller of my initial view. Had no idea where to place the second code block. As per the result of the first code block, the status bar didn't show up. I'm using iPhone6 Plus as simulator and same goes for iPhone 6 and below using iOS version 8. – David B Sep 25 '14 at 11:19
  • I just did on the my previous comment and the result was the status bar was still hidden. – David B Sep 25 '14 at 12:05
  • I wouldn't try mixing those two methods – Peter Johnson Apr 06 '17 at 00:46
9
  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];
hariszaman
  • 8,202
  • 2
  • 40
  • 59
  • Does is get displayed on iPhone6? If it did would it be the same if the project was created using XCode4? – David B Oct 03 '14 at 08:28
  • When I created a new project, it worked. Unfortunately, I have an existing project already created way back XCode4. Necessary changes were made for the update to XCode5 (suppoting iOS7) and now working on updates for XCode6 (supporting iOS8 & iPhone6). – David B Oct 03 '14 at 09:03
  • ok after the update make sure you build the project with ios8.0 sdk for iPhone6/plus simulator, also wehn you update xcode just add the previous sdks(iPhoneOS, iPhoneSimulator sdks) to xcode sdks, or better make symbolic link for those – hariszaman Oct 03 '14 at 09:29
  • I know the basics. Sorry. But I have a problem displaying the status bar on iPhone6. I will have to stick on my answer until someone answers on the related thread of mine [here](http://stackoverflow.com/questions/26174696/iphone6-6plus-landscape-status-bar-hidden). Thanks. – David B Oct 03 '14 at 09:36
2

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];
David B
  • 3,269
  • 12
  • 48
  • 80
0

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...

liamnichols
  • 12,419
  • 2
  • 43
  • 62
  • I see. Did Apple have an official statement about this behaviour? – David B Sep 25 '14 at 12:07
  • 1
    I know they mentioned it in WWDC sessions when going over all the Size Class/ Trait Collection stuff if that helps? – liamnichols Sep 25 '14 at 13:01
  • Apple does have an "official" statement, in WWDC 2014 session: "All right, now when I rotate this application to landscape, notice that our bars become condensed and the status bar disappears entirely." - Building Adaptive Apps with UIKit (Session 216) – Mustafa Oct 21 '14 at 05:40