-setStatusBarHidden:animated: is deprecated - iphone

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;

Related

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

Hiding status bar iOS 7

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.

xCode 4.6 - Status bar not appearing even when enabled for app

I started making updates to my app today. When I launch it in iOS Simulator (running xCode 4.6) the status bar is not visible during app launch (this is how I want it set, and how my app is setup in xCode) but then it is also not visible when I get to my Tab Bar Controller view and all my UIViewControllers (I have a tab based nav app).
The problem this creates is that the UIViewControllers, when displayed on a 4-inch display in iOS Simulator, it creates a small white space above the bottom Tab navigation bar (the height of which matches a status bar). I tried reverting my app to a previous backup but still can't get this fixed.
Help is appreciated. Thanks!
Using latest version of xCode (4.6)
iOS SDK 6.1
Try putting this when you want the status bar to reappear:
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
Hope this solves it.
OK write this line: [[UIApplication sharedApplication]setStatusBarHidden:NO];
in your appdelegate.m class under this method: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions & then check.

Iphone programming: remove bar

I'm not sure what it is called, but there is a bar at the top of the iphone screen with the time and battery. What is the simplest way to remove it?
In your Info.plist file, set UIStatusBarHidden to true. Also, you might have to add this in your app delegate:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
As a reminder, you might have to change the height in your NIB file since the bar is hidden. It might not change it automatically.
Go to your applicationDidFinishLaunching: in you app delegate and write this code..
[[UIApplication sharedApplication] setStatusBarHidden:YES];

How to get a black status bar on an iPhone app?

I want to use a black status bar for my iPhone app. I have selected black status bar on all of my .xibs but I still can't get it to be black. Is this an issue that anyone else has seen or knows how to remedy?
Open the "info.plist" file .
Add a new row.
Select "Status bar style" as the key.
Select "Opaque black style" as the value.
EDIT: The comment by #codrut below to choose the value:
If you go far to the right, there's a button that brings you a drop down with the possible options.
The status bar in the nib files is there as an indication, just to simulate the real interface.
What you need to do is:
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
and in the plist change the Status Bar Style (UIStatusBarStyle) to Black opaque (UIStatusBarStyleBlackOpaque) (or whatever you want).
Add the following in the info.plist file
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
Not sure if this will help anyone else, but in our app we ran into an issue where the only way we could get it to use the black style was if we set it to the default style:
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
Might be worth giving that a try if BlackOpaque isn't working for you.
Try this simple method....
1.For single viewController
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
2.For whole application
info.plist
----> Status Bar Style
--->UIStatusBarStyle to UIStatusBarStyleBlackOpaque