Reputation: 1451
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.
Upvotes: 11
Views: 2561
Reputation: 3233
It seems this was introduced into iOS 7.1 and affects non-retina iPads running iPhone applications with retina graphics.
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.
Upvotes: 10
Reputation: 11217
Add this code.
- (BOOL)prefersStatusBarHidden{
return YES;}
Upvotes: 0
Reputation: 869
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 :)
Upvotes: -1