1

I've just upgraded to XCode 5 and iOS 7. I've read all the suggestions I can find, but still getting the status bar appearing over the top of my apps.

I've tried setting View controller-based status bar appearance to NO in my plist:

enter image description here

I've tried adding:

- (void)viewDidLoad
{
    // …
    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
        // iOS 7
        [self prefersStatusBarHidden];
        [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    } else {
        // iOS 6
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    }
    // …
}

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

to my root view controller.

I don't know what else to try. Am I missing something obvious?

UPDATE

I've found that the status bar is only present on a couple of targets, while other targets running the same code don't have the status bar. I've checked all their plists... The only difference with the ones showing the status bar are that they display an advert bar at the top of the screen... I wonder if this could have something to do with it?

Slipp D. Thompson
  • 33,165
  • 3
  • 43
  • 43
Smikey
  • 8,106
  • 3
  • 46
  • 74
  • 1
    I think in XIB .status Bar set default position or none .try it – Bajaj Sep 25 '13 at 10:55
  • It was already set to none. Setting it to default had no effect... – Smikey Sep 25 '13 at 11:20
  • check it can't hide status bar in ios7/xcode 5 http://www.openfl.org/developer/forums/general-discussion/iphone-5ios-7-cant-hide-status-bar/ but Check this link also try it http://stackoverflow.com/questions/17763719/status-bar-wont-disappear – Bajaj Sep 25 '13 at 11:24
  • I've already tried the solutions in that post, as describe in the question – Smikey Sep 25 '13 at 11:27
  • Your plist Setting is Correct, just put This line `[[UIApplication sharedApplication] setStatusBarHidden:YES];` in `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method in `AppDelegate.m`. – Dipen Panchasara Sep 25 '13 at 11:29
  • so please check again and try to calling a method in view didload [self prefersStatusBarHidden]; and check again..hope so :( – Bajaj Sep 25 '13 at 11:35
  • I've trie both suggestions. No change, although strangely, it's only present on some targets. – Smikey Sep 25 '13 at 15:24

5 Answers5

4

Use - (BOOL)prefersStatusBarHidden { return YES; } in all of your view controllers. Good Luck!

Fahri Azimov
  • 11,470
  • 2
  • 21
  • 29
  • In ALL view controllers?! That can't be the solution surely? I have loads of them, and it doesn't seem to make a difference in the root so why would it help to have that return call throughout? – Smikey Sep 25 '13 at 11:24
  • I don't know in your case, in my case, it's solving the problem. Or, you can subclass `UIViewController`, and implement `prefersStatusBarHidden`, and make that class a super to all of your view controllers. – Fahri Azimov Sep 25 '13 at 11:33
  • And, by the way, what's your app's real root view controller? is it navigation controller or tabbar controller? – Fahri Azimov Sep 25 '13 at 11:35
  • It's a navigation controller... I shouldn't have to subclass UIVC. Thanks anyway though. – Smikey Sep 25 '13 at 15:23
  • So, if it's a navigation controller, do you still think that you are putting `prefersStatusBarHidden` in the right place? Try the way I have suggested, It should solve the problem. Or, there is also another way around, subclass the `UINavigationController` and implement `prefersStatusBarHidden` in that class, and use it. Good Luck! – Fahri Azimov Sep 26 '13 at 04:39
  • You only need to override -prefersStatusBarHidden in the root view controller of a navigation controller to have it apply to all its contained view controllers. – Drew C Nov 22 '13 at 19:51
1

In application .plist add this key: UIViewControllerBasedStatusBarAppearance and set it "NO"

Vlad
  • 3,465
  • 1
  • 31
  • 24
0

I ended up deleting the plist file and copying one from another target that did work, and then changing the necessary values. The lists were identical, however this appeared to fix it. I had already tried clean building, reseting the simulator etc, so I guess it was a bug in the plist/xcode.

Smikey
  • 8,106
  • 3
  • 46
  • 74
0

Try to add the next code in your root view controller:

- (BOOL)prefersStatusBarHidden { return YES; }
German Attanasio
  • 22,217
  • 7
  • 47
  • 63
0

Less hacky solution is to insert

[application setStatusBarHidden:YES]

in AppDelegate.m in method

- (BOOL) application(UIApplication *)application didFinishLaunchingWithOptions:(NSDirectory *)launchOptions

like Dipen Panchasara his: [UIApplication sharedApplication] delivers exact the application given in the methodcall.

Because changing a method to allways return YES feels not right

  • Unfortunately, this approach was deprecated after iOS 9.0.  The deprecation notice recommends overriding `UIViewController` `prefersStatusBarHidden` instead. – Slipp D. Thompson Sep 16 '16 at 00:18