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

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

问题描述

在我的.plist文件中,我将查看基于控制器的状态栏外观设置为。但是在 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天全站免登陆