UIImagePickerController 打破状态栏外观 [英] UIImagePickerController breaks status bar appearance

查看:9
本文介绍了UIImagePickerController 打破状态栏外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 .plist 文件中,我将基于控制器的状态栏外观"设置为 NO.但是在 UIImagePickerController 之后,我的应用程序的行为就好像该选项设置为 YES.

In my .plist file, I have "View controller-based status bar appearance" set to NO. But after UIImagePickerController, my app behaves as if the option is set to YES.

在我的应用中,我展示了一个 VC,它展示了一个 UIImagePickerController.

In my app, I present a VC that presents a UIImagePickerController.

问题是这样发生的:

  • 显示照片选择器后,选择照片库时,状态栏文本的颜色会发生变化.
  • 然后一次,UIImagePickerController被解散,状态栏间距应用其余部分的更改以及其他控制器的所有导航栏都显示在状态栏下方.
  • After photo picker is presented, when a photo library is picked, the color of the status bar text changes.
  • Then once, UIImagePickerController is dismissed, status bar spacing changes for the rest of my app and all the navigation bar for other controllers displays under the status bar.

有没有办法在不管理视图控制器中的状态栏的情况下解决这个问题?

Is there a way to solve this without managing status bar in my view controllers?

推荐答案

上述解决方案都不适合我,但通过结合 Rich86man 和 iOS_DEV_09 的答案,我得到了一个始终有效的解决方案:

None of the solutions above worked for me, but by combining Rich86man's and iOS_DEV_09's answers I've got a consistently working solution:

UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;

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


关于这个很棒的解决方案.对于 2014/iOS8,我发现在某些情况下,您还需要包括 prefersStatusBarHidden 和可能的 childViewControllerForStatusBarHidden 所以...


Regarding this awesome solution. For 2014 / iOS8 I found in some cases you need to ALSO include prefersStatusBarHidden and, possibly, childViewControllerForStatusBarHidden So...

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

-(BOOL)prefersStatusBarHidden   // iOS8 definitely needs this one. checked.
    {
    return YES;
    }

-(UIViewController *)childViewControllerForStatusBarHidden
    {
    return nil;
    }

-(void)showCamera
    {
    self.cameraController = [[UIImagePickerController alloc] init];
    self.cameraController.delegate = (id)self; // dpjanes solution!
    etc...

这篇关于UIImagePickerController 打破状态栏外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆