11

My iPhone app requires that the status bar be hidden at all times. This is generally easy to do, and it works if I only run the app on an iPhone. However, if I run the app on an iPad, the status bar still appears at the top of the content. So, how do I make sure the status bar is hidden no matter device my iPhone-only app is running on? I'm currently doing the following in my code:

Calling this method for each view controller(I actually created a category on UIViewController that implements this automatically for any VC, but it's basically the same as writing it in each vc file):

-(BOOL)prefersStatusBarHidden{
    return YES;
}

I also set "status bar is initially hidden" to YES and "View controller-based status bar appearance" to NO in Info.plist. I've also tried detecting which device is being used and calling

[UIApplication sharedApplication]setSetStatusBarHidden:YES]

in the AppDelegate, but no luck there either. So, I believe I've tried just about everything that one would think to try.

mike
  • 1,441
  • 2
  • 19
  • 31
  • I'm basically trying everything. Writing prefersStatusBarHidden in view controllers, setting "status bar is initially hidden" to YES and "View controller-based status bar appearance" to NO in Info.plist. I've also tried detecting which device is being used and calling [UIApplication sharedApplication]setSetStatusBarHidden:YES], but no luck there either. Just using prefersStatusBarHidden alone on my view controllers works when run on iPhone – mike Jan 10 '14 at 02:23
  • If I make this an Universal app, then my code works and the status bar is hidden on iPad. But, this app isn't meant to be universal, so this isn't a viable solution – mike Jan 10 '14 at 02:25
  • Well if you're setting prefersStatusBarHidden, "View controller-based status bar appearance" should be set to YES, you may already know this but you worded it a little strange. – Milo Jan 10 '14 at 02:41
  • Sorry, I meant to say that I've tried setting that key to both YES and then NO, but neither helps. – mike Jan 10 '14 at 02:44
  • check your code you did mistake some where – codercat Jan 10 '14 at 06:42
  • Sorry, but I don't think I made a mistake. If I compile my app as a Universal app, then the status bar is hidden as expected. However, running in 2x mode on iPad is when the status bar doesn't appear, so there has to be some other option or method that specifically hides the status bar on iPad when running an iPhone specific app – mike Jan 10 '14 at 16:50
  • Has there been any solutions to this as I am finding the same problem; is very frustrating. – Roddy Mar 24 '14 at 10:51
  • Refer to this question. I think [Hiding status bar from plist][1] [1]: http://stackoverflow.com/questions/18979837/how-to-hide-ios-7-status-bar – E-Riddie May 02 '14 at 19:26

3 Answers3

10

It seems this was introduced into iOS 7.1 and affects non-retina iPads running iPhone applications with retina graphics.

No solution for developers. I think Apple will have to patch this one...

Problem devices: iPad 2 iPad Mini (non-retina).

Problem does not exist in iOS 7.0 and status bar issues can be fixed for 7.0 with the other solutions posted.

Update for September 2014 - iOS 8:

This bug is fixed for iOS 8!!!!!

Danoli3
  • 3,203
  • 3
  • 24
  • 35
0

Add this code.

- (BOOL)prefersStatusBarHidden{
return YES;}
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90
-1

Add an property in YourViewController as

@property BOOL statusBarHidden;

and then in ViewDidLoad add the following lines of code

    [self prefersStatusBarHidden];
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    self.statusBarHidden = YES;

Then add an method in YourViewController

- (BOOL)prefersStatusBarHidden{
return YES;}

and also don't forgot to add the #import <UIKit/UIKit.h> in your code it works great for IOS6.1 & 7.0 :)

Prabhu Natarajan
  • 869
  • 1
  • 9
  • 13
  • Same issue with this code. Again, the issue only presents itself when running an iPhone app in 2x mode on an iPad. Otherwise, just using prefersStatusBarHidden is enough to hide the status bar. Thanks for the suggestion! – mike Jan 10 '14 at 16:49
  • You can try this link may it will help you to solve the problem http://forums.macrumors.com/showthread.php?t=1649030 – Prabhu Natarajan Jan 16 '14 at 07:18