Can't unhide status bar in iOS 7.1 - ios

I see people are having problems with hiding the status bar in iOS 7.1, but I have the opposite problem. I'm unable to unhide once it has been hidden. :)
This piece of the code works perfectly fine on both iOS 7 and 7.1. It will hide the status bar and show the image picker.
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
imagePickerController.showsCameraControls = YES;
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
}
self.imagePickerController = imagePickerController;
[self presentViewController:imagePickerController animated:YES completion:nil];
However, the part that is supposed to bring the status bar back doesn't work any more in iOS 7.1:
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
[self dismissViewControllerAnimated:YES completion:NULL];
This code will dismiss the image picker, but the status bar will remain hidden.
Any ideas how to solve this issue?

OK, I figured something out. The problem doesn't lie in setStatusBarHidden:NO itself, but in its combination with the image picker.
It seems that in iOS 7.1 the image picker (the camera one) will hide the status bar on its own (that wasn't the case in iOS 7.0). So, if I also hide it manually, the status bar is hidden twice and that seems to break something.
To conclude: hiding the status bar manually before showing the camera image picker is pointless in iOS 7.1 because the image picker itself will hide it.
Hiding and showing the status bar without using the image picker works just fine.

Related

UINavigationBar has wrong height because the status bar is hidden while loading

I have set a UITabBarController as the root view controller in the AppDelegate.
I have added a loading view upon the window, while the app downloads some data. I have hidden the status bar while the loading screen is visible. As soon as the loading is done, I fade the loading view and shows the status bar again.
My problem is that when I show the status bar the navigation bar was not drawn to have the right height, because the status bar was hidden when it was drawn. If I change to another tab it gets the right height.
I have tried with [navigationController.view setNeedsLayout], but that seems to get the position of the view of the ViewController right, but the content of the navigation bar does not resize. I have also tried with [navigationController.navigationBar setNeedsLayout], but that does help at all.
So I basically want to get the navigation drawer get the right height for the status bar and content when the loading view fades. How can I do this?
Have you try to reset the navigation and status bar as like below?
-(void)resetNavigationBar
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
}
I would unhide the status bar in the viewWillDisappear: method on the loading view.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}

Status bar when hidden navigation bar in iOS 7

I build app using UINavigationController is root view, i have issue hide navigation bar, when i hide navigation bar self.navigationController.navigationBarHidden = YES; status bar translucent not like status bar iOS 6 version like app Apple Store
How to fix it?
PS: I use UIBarPositionTopAttached to UIStatusBar like iOS 6
1.Add this line in your viewDidLoad to get default iOS6 style..
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
If you need default syle in whole app means try this.
info.plist
----> Status Bar Style
--->UIStatusBarStyle to UIStatusBarStyleBlackOpaque
2.Add following method to adjust status bar height in iOS7..
- (void)viewDidAppear:(BOOL)animated
{
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7) {
CGRect windowFrame = [UIScreen mainScreen].bounds;
windowFrame.origin.y+=20.0;
windowFrame.size.height-= 20.0;
self.view.frame = windowFrame;
[self.view layoutIfNeeded];
}
}
you can directly set status bar black opaque through plist add this key in .plist file
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
Thanks.

iOS status bar and UIView

There is UIView, status bar, iOS 7 and iOS 6.
With iOS 6 everything is good: my UIView (transparent, under "Tap to set destination" label) appears right below status bar. Here is the picture:
The problem is with iOS 7. Here:
I expect that UIView will be under status bar, not beneath it.
I have already tried to detect iOS version and if it's 7 or upper change UIView frame programmatically. But my UI with all the constraints made in storyboard... So it did not help. What can I do to resolve this problem?
UPD: maybe I really should make design more capable for iOS7? I'll think about it, and thanks for recommendations!
In your View Controller viewDidLoad, you should add:
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) {
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
If you really really need to do this you can place the map view inside another view that will be the root view of the controller. This root view will be under the status bar in iOS 6 and take full screen in iOS 7. Set black background for the root view.
Add constrains from this root view to the map view and in viewDidLoad: check iOS version. In iOS 7 change top constrain from 0 to the status bar height (or add contain to topLayoutGuide and remove the top constrain).
But again the behavior you see is normal for iOS 7, and trying to make you view under the status bar you make your app look old-fashioned. May be it's time to reconsider you design.
In iOS 7 that's the default behavior of status bar. I guess the easiest solution will be to hide the status bar all together.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
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;
}
Try many ways, I saw dozens of post. Finally this is the best solution I found.
Proper way to hide status bar on iOS, with animation and resizing root view

Status bar is not changing it's orientation

Hi I'm using the following code to rotate the orientation of the screen programmatically, without rotating the real device.
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown animated:NO];
It rotates everything except the status bar. Can you please tell me, how can I rotate everything on the screen programmatically?
Implement this in your viewController
- (BOOL)shouldAutorotate {
return NO;
}
Your root view controller required to answer NO to shouldAutorotate for your app to respond setStatusBarOrientation:animated method.

setStatusBarHidden stops working properly after UIDocumentInteractionController's presentPreviewAnimated

So my app has the status bar set to be hidden like this in the AppDelegate. And it works as intended.
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Then I use UIDocumentInteractionController's presentPreviewAnimated like this,etc.:
[self.docInteractionController presentPreviewAnimated:YES];
I observed that the status bar does show up (with battery info etc.) while in this UIDoc's preview mode. But after dismissing the preview and back to the original view, while the status bar is not there but there is a black bar instead. The size is same as the status bar.
Has anyone encountered this behavior and any remedy for this?
I am facing the same issue. Found a quick fix to this issue...set the view's frame back inside viewWillAppear... My code looks something like this...
-(void)viewWillAppear:(BOOL)animated {
... //other settings
self.view.frame = [[UIApplication sharedApplication].keyWindow bounds];
}
Hope it helps! :)

Resources