Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide the status bar in iOS 7.1?

In iOS 7.0, I hid the status bar in my apps by adding

<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

to the info.plist. I just updated my testing iPad to iOS 7.1, and the status bar is now back in all of my apps. How can I hide it in both 7.0 and 7.1?

Update: This is only happening in iPhone apps running on the iPad, I don't see this problem on the iPhone or in the simulator.

like image 540
Brian Avatar asked Mar 10 '14 19:03

Brian


People also ask

How do I hide my status bar on iPhone 7?

To completely hide it on the home screen, open up an app, such as Settings, and wait about three to four seconds. Press the home button again, and the status bar will be completely gone. The status bar will only be hidden on your home screen, so you'll still see it while using apps.

How do I hide the status bar on my iPhone?

Common Step. Go to Your info. plist file. Add a key called “View controller-based status bar appearance” and set its value to NO.

What is IOS status bar?

A status bar appears along the upper edge of the screen and displays information about the device's current state, like the time, cellular carrier, and battery level.


3 Answers

In the view controllers in which you want the status bar hidden, add the following method

- (BOOL)preferStatusBarHidden {
  return YES;
}

Then you can call

[self setNeedsStatusBarAppearanceUpdate];

which will fire the change to the status bar. This call can be done inside of an animation block which will animate the change.

like image 72
thedrick Avatar answered Nov 06 '22 13:11

thedrick


Try adding the following

   - (void)viewWillAppear:(BOOL)animated{
        NSLog(@"View will appear");
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

    }

    - (void)viewWillDisappear:(BOOL)animated{

        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    }
like image 32
4GetFullOf Avatar answered Nov 06 '22 12:11

4GetFullOf


I can reproduce the problem with a single-view iPhone-only app running in iPhone-compatibility mode in the simulator. But only when selecting an iPad non-retina on iOS 7.1.

My findings:

  • The status bar will not be hidden, whatever you specified in the plist or in code.
  • The problem doesn't occur on retina iPads
  • The problem doesn't occur on iOS 7 or iOS 6

I tried these keys in the .plist:

<key>UIStatusBarHidden</key>
<true/>
<key>UIStatusBarHidden~ipad</key>
<true/>

and

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance~ipad</key>
<false/>

I also tried the ViewController based-solution as mentioned by @Irfan to no avail.

There also seems no way to detect if the statusbar is shown as [UIApplication sharedApplication].statusBarFrame returns {0, 0, 0, 0}

like image 1
Mr. Morris Avatar answered Nov 06 '22 13:11

Mr. Morris