简体   繁体   中英

UIImagePickerController not always Fullscreen (strange Statusbar behavior)

i need a UIImagePickerCOntroller, so that the User can take some photos. This is my Code:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;
    imagePicker.showsCameraControls = YES;
    imagePicker.allowsEditing = YES;
    imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;


    [self presentViewController:imagePicker animated:YES completion:nil];

}

For the first time i open the UIImagePickerController everything works fine! But for the Second, third... time i always get this:

在此处输入图片说明

As you can see the Camera Controls above gets cut. It looks like the StatusBar is the Problem. I tried everything like:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
   [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

or

[[UIApplication sharedApplication] setStatusBarHidden:YES];

But nothing worked. Maybe an Apple Bug?

Try this :

  • Go to Info.Plist
  • Set Status bar is initially hidden YES
  • Set View controller-based status bar appearance NO

Implement - (BOOL)prefersStatusBarHidden in your view controller and return YES or NO based on the current conditions. When you want to hide/show, call - (void)setNeedsStatusBarAppearanceUpdate on your view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM