Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 UIStatusBarStyle Hide Status Bar During Application Launch Bug

I am updating my app to change the colour of my Navigation Bars from White to Blue. Therefore, I want to change the colour of the Status Bar from black to white. I've tried EVERYTHING from the Apple documentation, which helped me change the Status Bar Style for all my View Controllers in my Storyboard.

However, any nib I push to that is not in my Storyboard using presentViewController automatically changes the UIStatusBarStyle - here's my code for the push:

NSString *url = @"https://twitter.com/Example";
                NSString *title = @"Example";
SocialWebViewController *addController = [[[SocialWebViewController alloc] initWithURL:url title:title] initWithNibName:@"SocialWebView_iPhone" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
[self presentViewController:navigationController animated:YES completion:nil];

I've already placed the UIStatusBar preferred style in my AppDelegate, which WORKS, BUT ONLY for the ViewControllers in my StoryBoard:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

AND YES, I've already tried:

(1) [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

(2) [self setNeedsStatusBarAppearanceUpdate];

(3) Set the UIViewControllerBasedStatusBarAppearance to YES in the plist

NONE of this works for those Nibs not in my StoryBoard.

OK SO I FIGURED OUT WHAT YOU GUYS HAVE BEEN SAYING - SETTING View controller-based status bar appearance TO 'NO' HAS NOT BEEN WORKING FOR ME BECAUSE MY STATUS BAR IS INITIALLY HIDDEN DURING APPLICATION LAUNCH, WHICH HIDES IT ALL THE TIME WHEN I SET UIViewControllerBasedStatusBarAppearance to "NO"...How do I fix this?

like image 456
Bobi Avatar asked Jan 11 '14 02:01

Bobi


1 Answers

In your *-Info.plist file set the keys:

UIStatusBarStyle = UIStatusBarStyleLightContent
UIViewControllerBasedStatusBarAppearance = NO
UIStatusBarHidden = YES

And in your AppDelegate add this line to method application:didFinishLaunchingWithOptions:

[[UIApplication sharedApplication] setStatusBarHidden:NO];
like image 179
LuisEspinoza Avatar answered Nov 15 '22 08:11

LuisEspinoza