Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS SDK - How to get the status bar back when using UIImagePickerController?

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];
like image 673
dan Avatar asked Aug 22 '10 16:08

dan


3 Answers

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];
like image 52
Brad The App Guy Avatar answered Nov 20 '22 22:11

Brad The App Guy


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.

like image 15
alex Avatar answered Nov 20 '22 21:11

alex


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];
}
like image 6
Tim Avatar answered Nov 20 '22 23:11

Tim