Cannot hide status bar in iOS7

Objective CStatusbarIos7

Objective C Problem Overview


I just upgraded my iPhone 5 iOS 7 to four beta version. Now when I run my app from Xcode 5 on this iPhone, status bar doesn’t hide, even though it should.

Not Working:

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

Not Working:

[UIApplication sharedApplication].statusBarHidden = YES;

>Can't login to Apple Developer Forums

Objective C Solutions


Solution 1 - Objective C

in your apps plist file add a row call it "View controller-based status bar appearance" and set it to NO

Note that this simply does not work, if you are using UIImagePickerController in the app.

from http://www.openfl.org/developer/forums/general-discussion/iphone-5ios-7-cant-hide-status-bar/, mgiroux's solution

An example adding View Base Controller to your Info settings in Xcode

Solution 2 - Objective C

Add method in your view controller.

- (BOOL)prefersStatusBarHidden {
    return YES;
}

Solution 3 - Objective C

In the Plist add the following properties.

-> Status bar is initially hidden = YES

-> View controller-based status bar appearance = NO

Add both - now the status bar will disappear.

Solution 4 - Objective C

To hide Status Bar on a Single view, you should use:

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

At first, this didn't work for me, and then a saw in the documentation of this method that says: // Setting statusBarHidden does nothing if your application is using the default UIViewController-based status bar system.

This has to be done on the plist file, adding the key View controller-based status bar appearance set to NO. And then it worked.

Solution 5 - Objective C

In order to use the legacy UIApplication method to hide/show the status bar, your app must set a plist value for iOS 7:

View-Controller Based Status Bar Appearance = NO

This value is set to YES by default. If you change it to NO, you can use the legacy methods. If you leave it set to YES, you can still hide the status bar, but it's up to each view controller subclass in your app to override: prefersStatusBarHidden to return YES.

Any time your app needs the status bar appearance or visibility to change, and View-Controller Based Status Bar Appearance is set to YES, your outermost view controller needs to call:

setNeedsStatusBarAppearanceUpdateAnimation

Solution 6 - Objective C

To hide status bar in iOS7 you need 2 lines of code

  1. inapplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write

     [application setStatusBarHidden:YES];
    
  2. in info.plist add this

     View-Controller Based Status Bar Appearance = NO
    

Solution 7 - Objective C

There are so many combinations suggested for this issue, but the problem is that iOS 6 and 7 use different methods to hide the status bar. I have never been successful setting the plist settings to enable the iOS6-style behaviour on iOS 7, but if you are building your app to support iOS 6+, you need to use 3 methods at once to ensure a particular view controller hides the status bar:

// for ios 7 
- (BOOL)prefersStatusBarHidden{
    return YES;
}

// for ios 6
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    // explicitly set the bar to show or it will remain hidden for other view controllers
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}

This should work regardless of your plist settings.

Solution 8 - Objective C

I had to do both changes below to hide the status bar:

Add this code to the view controller where you want to hide the status bar:

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

Add this to your .plist file (go to 'info' in your application settings)

View controller-based status bar appearance --- NO

Then you can call this line to hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

Solution 9 - Objective C

Just add these 2 lines in info.plist file. It will make the fix for iOS7 and older version both.

  • Status bar is initially hidden = YES
  • View controller-based status bar appearance = NO

Navigate to the project and select Targets -> General and see the "Status Bar style ...Hide during application launch" check box will be checked. This will work.

Solution 10 - Objective C

Try this simple method:

- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}

- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}

Solution 11 - Objective C

The only thing that worked for me is to add the following in your plist

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

Solution 12 - Objective C

The easiest method I've found for hiding the status bar throughout the entire app is by creating a category on UIViewController and overriding prefersStatusBarHidden. This way you don't have to write this method in every single view controller.

UIViewController+HideStatusBar.h

#import <UIKit/UIKit.h>

@interface UIViewController (HideStatusBar)

@end

UIViewController+HideStatusBar.m

#import "UIViewController+HideStatusBar.h"

@implementation UIViewController (HideStatusBar)

//Pragma Marks suppress compiler warning in LLVM. 
//Technically, you shouldn't override methods by using a category, 
//but I feel that in this case it won't hurt so long as you truly 
//want every view controller to hide the status bar. 
//Other opinions on this are definitely welcome

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

#pragma clang diagnostic pop


@end

Solution 13 - Objective C

  1. In plist add ----

    View controller-based status bar appearance --- NO

  2. In each viewController write

    - (void) viewDidLayoutSubviews
    {
        CGRect viewBounds = self.view.bounds;
        CGFloat topBarOffset = 20.0;
        viewBounds.origin.y = -topBarOffset;
        self.view.bounds = viewBounds;
    
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];//for status bar style
    }
    

For status bar issue in iOS 7 but target should be 5.1 and above for the app

Solution 14 - Objective C

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

Solution 15 - Objective C

Many of the answers on this thread work, but it's my understanding if you're trying to do anything dynamic you'll eventually need to call:

[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];

Solution 16 - Objective C

Steps For Hide the status bar in iOS 7:

1.Go to your application info.plist file.

2.And Set, View controller-based status bar appearance : Boolean NO

Hope i solved the status bar issue.....

Solution 17 - Objective C

For iOS 7 in a single view use in viewWillappear method:

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

For display the status bar use:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];

Solution 18 - Objective C

In Info Plist file Add a row for following property

Property Name : View controller-based status bar appearance

Value : NO

Solution 19 - Objective C

Try adding the following method to your app's root view controller:

- (BOOL)prefersStatusBarHidden
    {
        return YES;
    }

Solution 20 - Objective C

I tried all these options posted here on my project and they would not work. I thought it could be to do with the fact I had updated my Xcode and then the app to iOS 7 and some settings had got messed up somewhere. I decided To build a completely new project for it and after simple just setting: "Status bar is initially hidden = YES" and "View controller-based status bar appearance = NO" as stated by many others it worked correctly (i.e. no status bar).

So my advice if you are working on a project which has been updated to iOS 7 from an old version and have tried all other options is to build a new project.

Solution 21 - Objective C

For 2019 ...

To make an app with NO status bars,

Click info.plist, right-click to "Add row".

Add these two, with these settings:

enter image description here

That's all there is to it.

Solution 22 - Objective C

You can check this code, pod UIViewController+ODStatusBar

Solution 23 - Objective C

For Swift 2.0+ IOS 9

override func prefersStatusBarHidden() -> Bool {
return true
}

Solution 24 - Objective C

To hide status bar for specific viewController

- (BOOL)prefersStatusBarHidden {
    return YES;
}

For setting status bar Hidden for application:

  • set View controller-based status bar appearance to NO in .plist and in application: didFinishLaunchingWithOptions: set: [application setStatusBarHidden:YES];

    > Note: setStatusBarHidden: deprecated

OR

  • in Project settings -> General Tab ->Deployment Info

    Check Hide Status bar box.

Solution 25 - Objective C

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
application.statusBarHidden = YES;
return YES;
}

Solution 26 - Objective C

I'm not sure why you "can't login to the Apple Developer Forums", but (without violating the NDA) you can also hide your statusBar through Xcode. It's a general setting on your application target. enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMelih B&#252;y&#252;kbayramView Question on Stackoverflow
Solution 1 - Objective CsatgiView Answer on Stackoverflow
Solution 2 - Objective CinvoodooView Answer on Stackoverflow
Solution 3 - Objective Cuser1179912View Answer on Stackoverflow
Solution 4 - Objective CDebora FortiniView Answer on Stackoverflow
Solution 5 - Objective CjaredsinclairView Answer on Stackoverflow
Solution 6 - Objective CShaik RiyazView Answer on Stackoverflow
Solution 7 - Objective CSaltyNutsView Answer on Stackoverflow
Solution 8 - Objective CPeter YView Answer on Stackoverflow
Solution 9 - Objective CSidView Answer on Stackoverflow
Solution 10 - Objective CRajesh LoganathanView Answer on Stackoverflow
Solution 11 - Objective CbartburkhardtView Answer on Stackoverflow
Solution 12 - Objective CmikeView Answer on Stackoverflow
Solution 13 - Objective Cuser2823580View Answer on Stackoverflow
Solution 14 - Objective CThunderbirdView Answer on Stackoverflow
Solution 15 - Objective CdarkheartfeltView Answer on Stackoverflow
Solution 16 - Objective CchandrikaView Answer on Stackoverflow
Solution 17 - Objective Coscar castellonView Answer on Stackoverflow
Solution 18 - Objective Cuser842553View Answer on Stackoverflow
Solution 19 - Objective CBhoopiView Answer on Stackoverflow
Solution 20 - Objective Cuser1529408View Answer on Stackoverflow
Solution 21 - Objective CFattieView Answer on Stackoverflow
Solution 22 - Objective CAlex NazarovView Answer on Stackoverflow
Solution 23 - Objective CIrshad QureshiView Answer on Stackoverflow
Solution 24 - Objective CLal KrishnaView Answer on Stackoverflow
Solution 25 - Objective CEvan IscheView Answer on Stackoverflow
Solution 26 - Objective CJakeView Answer on Stackoverflow