Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide status bar in iOS 7?

I have tried setting the following in my app .plist file:

View controller-based status bar appearance: NO

And while this removes it from my initial view controller, once I go to another view and come back with my navigation controller, it comes right back and this time it does not disappear. Also, I don't see why it would matter but I have also set the status bar under simulated metrics to "None" but that doesn't seem to help. I know i am going to have the navigation bar but the status bar I need gone.

enter image description here

How can I get this done? Please provide a detailed answer, sample code would be great!

Update: This is NOT a duplicate solution as I have tried all other solutions and NONE seem to work for me. Most recently I tried

[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

Again, with no results. When the app initially launches a status bar is NOT present, after the user visits another view, the status bar is now present in the 2 and other views and does not go away. Even if you go back to the main view.

like image 806
vzm Avatar asked Jan 27 '26 02:01

vzm


2 Answers

I have tried all of the suggestions that were posted here, unfortunately what happened here was a small mistake, in my viewDidLoad I had:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

But in my viewWillAppear I had:

[[UIApplication sharedApplication] setStatusBarHidden:NO];

So this was just an issue of overriding, problem fixed now.

like image 142
vzm Avatar answered Jan 29 '26 18:01

vzm


To hide status bar:

if [View controller-based status bar appearance: NO]: in AppDelegate.m call

[[UIApplication sharedApplication]setStatusBarHidden:YES];

else: in every view controller

- (BOOL)prefersStatusBarHidden
{
    return YES;
}
like image 29
Wubao Li Avatar answered Jan 29 '26 18:01

Wubao Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!