user2816721
user2816721

Reputation: 101

Status bar not rendering as expected on iPad

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

Upvotes: 5

Views: 3439

Answers (4)

hariszaman
hariszaman

Reputation: 8432

Combination of :

  1. View controller-based status bar appearance = NO

  2. Status bar style = UIStatusBarStyleLightContent

worked for me

Upvotes: 0

user2816721
user2816721

Reputation: 101

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.

Upvotes: 5

Wayne Hartman
Wayne Hartman

Reputation: 18497

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

Upvotes: 8

Jakob W
Jakob W

Reputation: 3377

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

Upvotes: 0

Related Questions