UIImagePickerController并不总是全屏(奇怪的状态栏行为)

时间:2014-04-01 09:30:39

标签: ios objective-c uiimagepickercontroller statusbar uistatusbar

我需要一个UIImagePickerCOntroller,以便用户可以拍摄一些照片。这是我的代码:

- (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];

}

我第一次打开UIImagePickerController一切正常!但对于第二,第三......时间我总是得到这个:

enter image description here

正如您所看到的,上面的相机控制被切断了。看起来StatusBar就是问题所在。我尝试了一切:

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

[[UIApplication sharedApplication] setStatusBarHidden:YES];

但没有任何效果。也许是Apple Bug?

2 个答案:

答案 0 :(得分:0)

试试这个:

  • 转到Info.Plist
  • 设置状态栏最初隐藏为是
  • 设置基于视图控制器的状态栏外观NO

答案 1 :(得分:0)

在视图控制器中实施- (BOOL)prefersStatusBarHidden,并根据当前条件返回YESNO。如果要隐藏/显示,请在视图控制器上调用- (void)setNeedsStatusBarAppearanceUpdate