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
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
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.
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]
Set in the .plist – UIStatusBarStyle = UIStatusBarStyleLightContent
Set in the .plist – UIViewControllerBasedStatusBarAppearance = false
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With