5

I am struggling with an ios7 / objective-c issue that hopefully someone will be able to help me with.

As some background, I have an app that is rendering as expected on io6 devices, but I trying to bring it into compliance with ios7.

Where things have gotten confusing is the fact that my code is working as expected on the iPhone but it is not on the iPad.

From the images below you will see that the status bar (carrier, time, battery) renders as expected on the iPhone but not the iPad:

First the iPhone

Now the iPad:

(note: due to this being my first posting, I can't directly embed the images, sorry about that).

From the coding point of view, I have tried all the suggestions indicated at: How to change Status Bar text color in iOS 7 without any luck.

What I do have that makes the App render as expected is the following definition in my AppDeligate.

// News page
newsViewController = [[NewsViewController alloc] init];
newsNavigationController = [[UINavigationController alloc] initWithRootViewController:newsViewController];
newsNavigationController.navigationBar.translucent = NO;
newsNavigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
newsNavigationController.navigationBar.tag = 4013;

Now I think that issue is that even though I have set the bar style to UIStatusBarStyleLightContent, which should put the text in white, it is not doing this on the iPad. Instead it renders as black on black.

This seems to be the case, because if I remove the line:

newsNavigationController.navigationBar.translucent = NO;

the black changes to a dark gray, and the carrier, date, battery, can be seen BUT in the black. I am willing to live with the dark gray vs the black background, but the status bar items will need to render in white like the iphone.

Any suggestions?

P.S. I am not sure if this will help point things in the right direction, but the iPad is using a splitview controller.

Thanks

Community
  • 1
  • 1
user2816721
  • 101
  • 1
  • 6
  • Just to add, the issue does seem to be related to the UISplitViewController. If I remove it, the status text DOES render in white as expected. – user2816721 Sep 25 '13 at 22:16

4 Answers4

8

Because the status bar is going to use the preference of the root view controller, adjusting the preferred status bar style for your navigation controllers will not work on iPad, since none of them are the root view controller. You must, therefore, override preferredStatusBarStyle in a subclass of UISplitViewController.

@implementation DGBaseSplitViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

@end
Wayne Hartman
  • 17,629
  • 5
  • 82
  • 114
  • This is i.m.o the best solution – ullstrm Mar 18 '14 at 15:24
  • This is the only thing that worked for me. Before it would work, I also had to make sure and set the Split View Controller in my iPad storyboard to the new subclass in addition to reassigning the class in the app delegate. – jbcaveman May 20 '14 at 18:40
5

Sub-classing the SplitViewController as recommended by Wayne, might very well be a valid solution, but this is what I ended up doing that solved the problem for my purposes.

  1. Set the UI Status Bar Hidden = TRUE (I don’t want the status bar on the splash screen) [which is stored in the .plist as UIStatusBarHidden=true & UIStatusBarHidden~ipad = true]

  2. Set in the .plist – UIStatusBarStyle = UIStatusBarStyleLightContent

  3. Set in the .plist – UIViewControllerBasedStatusBarAppearance = false

  4. In my AppDeligate, near the top, I added the line:

    [UIApplication sharedApplication] setStatusBarHidden:NO];

    Which takes care of re-displaying the status bar after the splash screen is displayed.

user2816721
  • 101
  • 1
  • 6
0

Try putting Status bar style~ipad : UIStatusBarStyleLightContent in your info.plist.

Jakob W
  • 3,340
  • 17
  • 27
  • Thanks for the suggestion, but unfortunately no love. I also tried a generic entry of just "Status bar style" set to UIStatusBarStyleLightContent and that did not help either. – user2816721 Sep 25 '13 at 19:57
0

Combination of :

  1. View controller-based status bar appearance = NO

  2. Status bar style = UIStatusBarStyleLightContent

worked for me

hariszaman
  • 7,457
  • 2
  • 35
  • 53