Hiding status bar iOS 7 - iphone

Can't hide status bar on view controller on ios 7 device.
Already tried setting through plist file and also in Appcontroller.mm but still i doesn't hide the status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES];//Doesn't help

Go to info.plist and add two attributes if not present. set "Status bar is initially hidden" to YES and set UIViewControllerBasedStatusBarAppearance to NO. This will hide status bar for your app.

That's because iOS 7 has changed the way it deals with the status bar.
Setting UIViewControllerBasedStatusBarAppearance to NO on your app Info.plist should work.

I had the same issue recently. Be sure that you are targeting the correct view controller. Try to hide the status bar in the root view controller. Also, I´m implementing the method (BOOL)prefersStatusBarHidden (doc) in my UIViewControllers to hide the status bar. By using this method, you can forward the preferred configuration to a "child view controller". Also, this method works fine in UIViewControllers presented as modal.

// for ios 7
- (BOOL)prefersStatusBarHidden
{
return YES;
}
// for ios 6
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}

For iPad (iOS 7.0) need to put another value at Info.plist file.
UIStatusBarHidden boolean value YES.

Related

How to change UIViewControllerBasedStatusBarAppearance to YES/NO programmatically in iOS 7?

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only green battery indicator in the corner. How can I change the status bar text color to Green or Orange like it is on the home screen?
I know about
Set the UIViewControllerBasedStatusBarAppearance to YES in the plist
In viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
Add the following method:
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
How can I change UIViewControllerBasedStatusBarAppearance programmatically?
Thanks in advance...
In Info.plist set 'View controller-based status bar appearance' as NO.
then,add this in your appdelegate.m class in didfinishlaunchingwithoptions method.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
this works for ios 7.
As mention by others add "View controller-based status bar appearance' in your application's info.plist and set it to Type: Boolean and Value: NO
For your ready reference:
In iOS 9
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
method is deprecated.
So you can use this:
application.statusBarStyle = UIStatusBarStyleLightContent;
add this line of code in method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
which is present in appDelegate.m file. This will change the status bar text color throughout your application.
So if you have any screen which has background may be dark or light then in that screen you can the status bar color by making use of:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
Hope this helps.

Getting rid of the abominable status bar is not that easy as it seems on iOS 7

I have this app compiled for iOS 6.0 running on iOS 7.
I am trying to get rid of the status bar and I am almost there.
I have added this to info.plist
View controller-based status bar appearance = NO
Status bar is initially hidden = YES
I have added this code to the rootViewController
- (BOOL)prefersStatusBarHidden
{
return YES;
}
Everything is fine. The app loads without the status bar but as soon as I present the UIImagePickerController from the rootViewController the status bar is back, even after the picker dismisses.
Yes, I have subclassed the UIImagePickerController and added the prefersStatusBarHidden to the class, just to see, but nothing changed.
How do I get rid of this abomination. Please save me.
EDIT: no,
[self setNeedsStatusBarAppearanceUpdate];
is not working
Had this exact same problem in my app. Solution that worked - Assuming that the view controller that shows the UIImagePickerController implements the UINavigationControllerDelegate protocol. Implement this protocol method -
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
}
Check this answer: How to hide iOS status bar
and these new methods: https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/childViewControllerForStatusBarHidden
https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/prefersStatusBarHidden

Hide Status Bar from iPhone application

I want my app to not have the status bar at all! I have tried using the .plst
I have tried everything in here Status bar won't disappear
and also in here
How to prevent iOS 5 from showing the status bar even though UIStatusBarHidden is YES?
Can someone go into extreme detail to help me? I am using XCode 5 if that helps. I just want the status bar to be gone from the app!
Thanks!
iOS 7
In your Info.plist file add key View controller-based status bar appearance with value NO. And, add key Status bar is initially hidden with value YES.
To hide the status bar after the app has completely launched, change it programmatically by adding this line to your app delegate's applicationDidFinishLaunching method:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
If you set animated to YES then the status bar will disappear by fading out. One question, why do you want to delete the status bar?
in your "*project_name*-Info.plist" file, add a key named "Status bar is initially hidden" and then set the value to "YES". that will always hide the status bar.
//viewDidload
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
// Add this Method
- (BOOL)prefersStatusBarHidden
{
return YES;
}
Have you tried this:
click on .xib file -> attribute inspector -> change 'Status Bar' to 'None'
(refer attached image)
Open your application Info.plist file and add the following lines:
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<true/>
Please add this to your view controller
- (BOOL)prefersStatusBarHidden {
return YES;
}

-setStatusBarHidden:animated: is deprecated

At the start of my app, the status bar is hidden, due to the Info.plist setting called Status bar is initially hidden. Later on, I want to show the status bar using:
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
but I get a warning saying that the function is deprecated. Does anybody know what the new function is?
setStatusBarHidden:withAnimation: is the new method, which takes a UIStatusBarAnimation instead of a BOOL, so you can choose what animation is used to hide the status bar.
It is:
- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation
See the UIApplication class reference for more info.
If you are trying to write code for both iOS 3.x and iOS 4.x, you are going to run into a further issue that the new method is not available in the old iOS. See this question for further info.
Add this to your AppDelegate.m
[UIApplication sharedApplication].statusBarHidden = YES;

Hiding status bar completely

I hide the status bar in applicationDidFinishLaunching using
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
That works fine except the status bar is there while the app is loading. Meaning, when the default.png is displayed, I see the status bar. Is there a way to have the status bar not show at all?
Add UIStatusBarHidden to your info.plist file, set to true. Documentation here:
http://developer.apple.com/library/ios/ipad/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
You need to use this:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
and then open up the info.plist file, create a new line, chose Status bar is initial hidden and set it to true.
You need to edit your Info.plist to include the entry "Status bar is initially hidden" and set the value to YES.
For more information:
http://www.idev101.com/code/User_Interface/StatusBar.html