As soon as I add a UIImagePickerController sub view to my view the status bar disappears and I can't get it back. Is there any way to keep the status bar visible?
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.view addSubview:imagePicker.view];
[imagePicker viewWillAppear:YES];
[imagePicker viewDidAppear:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
I had to do the same thing in a camera app as well. Apparently, in addition to setting the status bar to not be hidden, you also have to reset its style after the camera view makes it disappear. Try this:
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
The accepted answer's solution got deprecated meanwhile.
Use
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
instead of
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
Valid values for the animation parameter are UIStatusBarAnimationNone
, UIStatusBarAnimationFade
, UIStatusBarAnimationSlide
. Details are found in the documentation.
After reading this and finding none of the answers worked, I managed to get it working by doing the following:
• Setting a delegate for the UIImagePickerController
• In that delegate, hide the status bar in the delegate's navigationController:didShowViewController:animated:
function.
E.G:
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With