setStatusBarHidden not working
ios
Solution
In your app's plist, if you have "View controller-based status bar appearance" set to YES, put this code in the view controller in which you hide the status bar:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Else if "View controller-based status bar appearance" is set to NO, call the following whenever you want to hide the status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Problem
In my `UIViewController`, I have: ``` - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; [self.view sizeToFit]; } ``` Yet the view looks like this: I'm sure this code runs. I load the view from a `xib`. I haven't done anything else to the status bar like change its style. What could be wrong? Even when I set `application.statusBarHidden = YES" in my app delegate, I see: