views:

296

answers:

3

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];
+2  A: 

Add your UIImagePicker to the root view (i.e. a Navigation Controller or TabbarController)

[self.tabBarController presentModalViewController:imagePickerController animated:YES];

After that you can use

- (void)imagePickerController:(UIImagePickerController *)picker 
            didFinishPickingImage:(UIImage *)image
                      editingInfo:(NSDictionary *)editingInfo
{
      // do your stuff
     [picker dismissModalViewControllerAnimated:YES];
}

to close your ImagePicker.

Henrik P. Hessel
Hi Henrik, thanks for your reply. I want the status bar visible all the time. Is that possible?
dan
A: 

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];
Brad Smith
A: 

Where exactly do you call the setStatusBarHidden:NO Is in viewDidAppear? I added both these calls in viewWillAppear and also viewDidAppear, but the status bar remains hidden.

jamihash