setStatusBarHidden deprecated, but only thing that works - ios

I've tried all the solutions I can find including those in: setStatusBarHidden is deprecated in iOS 9.0 but none of them work with my application.
It is a simple, single view application. There is a Navigation bar with a single button on it which the status bar should show on top of.
In my .plist:
Status bar is initially hidden: NO
Status bar style: UIStatusBarStyleLightContent
View Controller based status bar appearance: NO
Changing any of these doesn't seem to make any difference at all. I have the status bar style "Hide during application launch" option checked as I don't want it to appear on the splash screen.
I have:
- (BOOL)prefersStatusBarHidden
{
return NO;
}
-(UIStatusBarStyle)preferredStatusBarStyle
{
NSLog(#"style");
return UIStatusBarStyleLightContent;
}
and setNeedsStatusBarAppearanceUpdate which are definitely all called when the view loads in my ViewController.
The view is established in a .storyboard, but many of the fields are manipulated in the ViewController.m as well. The value assigned to the status bar in the simulated metrics doesn't seem to have any effect either.
I need my status bar to be hidden during the launch screen and visible on the viewController. Please help me find a solution that doesn't use the deprecated setStatusbarHidden!
EDIT:
I still haven't solved this, and I surely can't be the only one with this problem! It happens in both apps that I have written.

I've just been trying to solve the same problem, I don't know why the setStatusBarHidden and setStatusBarStyle have been deprecated as the new methods are not at all intuitive.
To hide the status bar on launch I have these settings in my plist:
View controller-based status bar appearance: YES
Status bar is initially hidden: YES
Then to show the status bar after launch I have in my view controller:
- (BOOL)prefersStatusBarHidden {
return NO;
}
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
This still didn't work until I found this answer https://stackoverflow.com/a/19365160/488611. So in viewDidLoad I also set the navigation bar style:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Which makes absolutely no sense, but works.

you can use
application.statusBarHidden=YES;
in AppDelegate.m
didFinishLaunchingWithOptions

In my mind, you should change the value of UIViewControllerBasedStatusBarAppearance.
Set the value file .plist of project a is
UIViewControllerBasedStatusBarAppearance = NO
and check in file AppDelegate and set the code
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Hope my solution can be solved your problem.

OK, I totally misunderstood your question. Here's the correct answer.
Add the below value to you 'info.plist'.
Status bar is initially hidden : YES
View Controller based status bar appearance : YES
On UIViewControllers which you want to show status bar
- (BOOL)prefersStatusBarHidden {
return NO;
}
That's all.

I am not an expert on this, but I played with these settings for some time and came to the following conclusions.
General/Deployment Info:
Status Bar Style: Default (black), Light
Hide status bar (checkbox)
Both change the status bar on the launch screen only.
Note that if you take a screen shot to create this image and the screen shot included a status bar, it will appear that the device is setting the status bar even if you have checked the Hide status bar checkbox! I was tricked by this for a while before I finally thought to look at the launch image itself, and there was a status bar in the photo, so setting Hide never seemed to work even though it really was working. I removed the status bar from the images themselves using Photoshop, and the launch status bars functioned as expected after that.
Info/Custom iOS Target Properties (these change the values in the PLIST, so you could change them in either place):
Status Bar Is Initially Hidden: Yes/No
Status Bar Style: Gray (default), Transparent Black, Opaque Black
View Controller based status bar appearance : Yes/No
If you set Status Bar Is Initially Hidden to No, then you will have the status bar on your View Controller like you wanted. If you want to hide the status bar on your View Controller, you have to set Status Bar Is Initially Hidden to Yes AND set View Controller based status bar appearance to No.
Attributes Inspector for the View Controller/Simulated Metrics
Status Bar: None, Inferred, Default, Light, Black (deprecated)
This seems to have no effect on anything except the appearance of the view controllers in the StoryBoard but NOT in the simulator.
Summary: To answer your question, under General Deployment Info, check the checkbox that says Hide Status Bar. This will hide the status bar on the launch screen. Make certain that your image for the launch screen does NOT have a picture of a status bar in it. None of the settings in the StoryBoard or in the Target seems to turn off the view controller's status bar, so it seems that it will stay on like you wanted. However, I did not test any of the programmatic settings; I think that you should not do any of those, and it will work the way you want.

Related

Can see Status Bar space but not information in iOS Swift

I add Navigation Controller(2nd View) and add one UIViewController(3rd View) as root view controller.
And then I connect segue to Navigation Controller(2nd View) from anther UIViewController(1st View).
So I can see navigation Bar with Status bar space when the view is presented.
But the information like Carriers, batteries, time information are not shown in Status Bar.
(I changed navigation Color to pink for showing you the problem.
The blue part is title view for navigation bar.)
So I tried 2 solutions.
First, I thought StatusBar Color problem. But it was not.
UIApplication.shared.statusBarStyle = .default
Second, I tried following code for showing. It was not also.
override var prefersStatusBarHidden: Bool {
return false
}
and
UIApplication.shared.setStatusBarHidden(false, with: UIStatusBarAnimation.none)
I need to solve this not-showing problem with status Bar.
I can see status Bar space but not information.
There are lots of ways to toggle the color and visibility of the status bar in iOS.
Similar question with possible correct answers for you:
How to change Status Bar text color in iOS 7
In short, if you want to toggle it between every screens, follow these steps:
In your info.plist, add this new key:
View controller-based status bar appearance and value should be NO.
In your viewWillAppear, toggle the status bar with the code you have posted:
UIApplication.shared.statusBarStyle = .lightContent - white
or
UIApplication.shared.statusBarStyle = .default - black
Edit:
Initial ViewController --> Present Modally --> NavigationController + ViewController.
This is how you set up your screens, right?. If so,
You can setup the status bar in your NavigationController properties in your Interface Builder.
And toggle the visibility and/or color of your status bar in side the viewWillAppear of your 3rd ViewController.
I suggest you check out Debug View Hierarchy.
Based on my experiences in previous projects, if I can't come up with code-based solutions on UI-related problems the simplest debugging technique that I can do is check the view hierarchy during run time.
See if the Navigation Controller View blocks the Main View which can possibly hide the status bar and if yes, work your way on solving it.
I hope it helps.

Is there a way to call prefersStatusBarHidden without View controller-based status bar appearance set to NO?

There are lots of questions about toggling status bar visibility in iOS. I know them all but not this one (see my question above).
These are my cases:
View controller-based status bar appearance in my info.plist is NO - this is necessary because I'm toggling my view controllers' status bar color almost every screen. I don't want to start bothering with my base controllers again with this.
The key Status bar is initially hidden is set to YES. - Well for now, I really need to hide my status bar in my splash screen until the third party I use updates to let developers configure it not to mess with the status bar.
With the #2 case above, the first screen has now no status bar.
Status bar is initially hidden works even if I have the #1 case above, but is deprecated.
Any ideas?

iOS 7 Cannot See Status bar (Signal , Time, Battery) When I Fixed Navigation Bar overlap TableView

I fix problem iOS 7, Navigation Bar is Overlap Table View.
I use this Code
//for help navigation bar overlap
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
I can fix this problem but navigation bar overlap status bar not show signal battery time same this picture:
Actually your status bar is visible but your status bar text color is black so you can't see properly. if you just see from upside of your mac screen you can see this.
So follow the smita's answer is current but after change in plist you need to change it statusBar style with UIStatusBarStyleLightContent that change to your statusbar text color black to white.
In to your image that already display that clock time signal or battery status. with black color and your navigation bar tint color already black so that both are match. that's why you can not see that.
But only setting this line of code not enough.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
You need to change in to plist like
add one row with UIViewControllerBasedStatusBarAppearance set to NO. like bellow
now run you project that your navigation and statusbar look like:-
In your AppDelegate's didFinishLaunchingWithOption method add this line of code -
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
May this will help you.
In IOS7, if you want status bar depending on the view controller you can set the "View controller-based status bar appearance" in info-plist to "YES".
Override following method in all your controller to decide whether your that view need status bar or not.
-(BOOL)prefersStatusBarHidden

Status Bar appears in QLPreviewController after toolbar reappers

Status bar is initially hidden in Info.plist with "Status bar is initially hidden" set to YES and "View controller-based status bar appearance" set to NO.
But when I present a QlPreviewController, after two taps to document to make toolbar disappear and appear again, status bar appears in application too.
Any idea how to prevent this from happening?
In your Info.plist file, set UIViewControllerBasedStatusBarAppearance as true. Then in all view controllers that you want to hide the status bar add the following code:
- (BOOL)prefersStatusBarHidden {
return YES;
}
By doing this and create a sub class of QLPreviewController I was able to hide the status bar, even after returning from full screen state.

CardIOPaymentViewController hiding status bar

I'm having trouble hiding the status bar with my CardIOPaymentViewController. None of my other views display the status bar. I'm using the Card.io SDK in iOS7 and it presents fine modally - just that the status bar is always shown with this view. My info.plist has:
Status bar is initially hidden = YES
View controller-based status bar appearance = NO
and I've checked the Hide During Application Launch option in the Deployment Info Section.
I've tried:
self.keepStatusBarStyle = YES;
I've also made sure my CardIOPaymentViewController controller has (which I didn't need for my other view controllers):
-(BOOL)prefersStatusBarHidden {
return YES;
}
Any suggestions or similar experiences?
#rizjoj I believe that I have now identified and fixed the problem -- the CardIOPaymentViewController wasn't respecting the "View controller-based status bar appearance" setting.
But before I post an official update, I'd like to send you the updated SDK to test. My email address is in my profile; could you get in touch?

Resources