Status bar icons disappear and then slowly reappear - ios

I have found that the status bar will disappear when swapping the window's root view controller.
I have View controller-based status bar appearance set to NO
I am swapping between two different view controllers via
[UIApplication sharedApplication].delegate.window.rootViewController = rootVC;
Immediately upon displaying the new rootVC the status bar icons all disappear and slowly (10 seconds) begin to reappear. During this time the UI is responsive otherwise. I am not otherwise setting the visibility of the status bar via any method that I know to set the status bar visibility. Neither the old or the new rootVC are displayed as a modal.

So I found that if I changed the View controller-based status bar appearance plist property to YES and called [self setNeedsStatusBarAppearanceUpdate] from the new rootVC the statusbar icons didn't change.

Related

How can I ensure iOS 13 modal view controllers present the right status bar colour?

With the new iOS 13 view controller changes, view controllers are being presented that don't cover the whole screen. They instead leave a black space at the top. However, the system status bar is not changing colour automatically. When I present a modal view controller, the status bar is staying with now-invisible black text (and a green battery which looks super weird in the middle of nowhere).
How do I make the bar behave in the same way as within Apple's apps, where the bar animates to different colour when a modal popup appears?
I've tried setting modalPresentationCapturesStatusBarAppearance to true on my modal controllers, to no luck.
The bar in my presenting view controller is a UINavigationBar, and is not part of a navigation controller. The presenting VC is its delegate, and I've overridden position(for bar: UIBarPositioning) to return .topAttached.
I've tried presenting the modal with .modalPresentationStyle = .formSheet and without setting .modalPresentationStyle at all. Neither worked.
Broken:
The presenting VC:
Expected Behaviour:
Two things:
The modal view controllers need to have VC.modalPresentationCapturesStatusBarAppearance = false. This is the default but if, like me, you set it to something else, make sure it's false!
You need to ensure that View controller-based status bar appearance in your info.plist is set to YES. I'd messed around with it in an attempt to make my status bar the right colour but having it set to NO was a problem.

setStatusBarHidden deprecated, but only thing that works

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.

Removing Status Bar In IOS 8 When Using A UINavigationController

I am trying to remove the status bar from my app when moving between views in a UINavigationController.
I have a UINavigationController that has the status bar removed. I then select an image using UIImagePickerController, I think it is this that is resetting the status bar appearance.
After selecting the UIImage I push another view and present the image, the problem is that the status bar has reappeared.
I have tried a number of approaches including calling prefersstatusbarhidden on both views without without any luck.
Any ideas how to remove the status bar?
Thanks
If using iOS8, add
-(BOOL)prefersStatusBarHidden{
return YES;
}
to your view controller. You will need to add this to each view controller as required.
You could alternatively specify a value for the key View controller-based status bar appearance in info.plist to specify your status bar preferences app-wide.
Try hiding the status bar manually using this
[[UIApplication sharedApplication] setStatusBarHidden:YES];

ios 6 navigation bar and status bar overlapped

The problem is like this:
My status bar is intially hidden.
I have a tab bar controller and it has a navigation controller in each of its tabs.
Screen shot is like:
Later I clicked on a button on the navigation controller's view, I would like to reveal the status bar, but it ends like this:
the navigation bar overlaps the status bar. I have to perform some actions like tapping another tab to make the navigation bar go down.
I tried to set status bar to UIStatusBarStyleBlackOpaque and it worked fine.
But if I press the "home" button on iphone to turn the app to bacground and the switch back to active, the problem occurs again if I clicked on the button.
Your status bar style is UIStatusBarStyleBlackTranslucent. You should set it to either UIStatusBarStyleDefault or UIStatusBarStyleBlackOpaque for the desired effect.
Translucent status bars overlap the full screen views, while opaque ones push those views down.
click on button, do following things:
self.wantsFullScreenLayout = NO;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; //or UIStatusBarStyleDefault

iOS 7: How to force navigation bar of UINavigationController to be laid out as if status bar is showing even when status bar is hidden

Is there a way to force the navigation bar of a UINavigationController to be laid out as if the status bar is showing even when the status bar is hidden? My motivation is to prevent the navigation bar for shifting when a navigation controller presents a view controller that returns YES for prefersStatusBarHidden. An example of this is when you look at an attached image in an email in the Gmail app.

Resources