iOS 7 StatusBar问题,当我使用UIImagePickerController时允许编辑

Nit*_*hel 7 uiimagepickercontroller ios uistatusbar ios7

我研究相关的iOS 7状态 - Bar Maintain,但我在使用时遇到了问题UIImagePickerController.允许编辑"编辑窗口"在顶部栏显示20像素空间.

我使用的代码和第一I设置UIViewControllerBasedStatusBarAppearanceNOinfo.plist与设置委托方法:

Appdelegate.h

@property (retain, nonatomic) UIWindow *background;
Run Code Online (Sandbox Code Playgroud)

Appdelegate.m

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

    [application setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window.clipsToBounds =YES;
    self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);

    self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);

    background = [[UIWindow alloc] initWithFrame: CGRectMake(0, 0, self.window.frame.size.width, 20)];
    background.backgroundColor =[UIColor redColor];
    [background setHidden:NO];
}
Run Code Online (Sandbox Code Playgroud)

在我的家庭视图控制器中没有任何效果,所以我放入了我的home viewController,一种用于更改状态栏背景颜色的方法:

-(void)viewWillLayoutSubviews{

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    self.view.clipsToBounds = YES;
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenHeight = screenRect.size.height;
    self.view.frame = CGRectMake(0, 20, self.view.frame.size.width,screenHeight-20);
    self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"userIsMale"]) {
        [tempWindow setBackgroundColor:[UIColor colorWithRed:(46.0/255.0) green:(134.0/255.0) blue:(255.0/255.0) alpha:1]];
    }
    else {
        [tempWindow setBackgroundColor:[UIColor colorWithRed:(246.0/255.0) green:(26.0/255.0) blue:(113.0/255.0) alpha:1]];
    }

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
Run Code Online (Sandbox Code Playgroud)

现在当我出现UIImagePickerController允许编辑窗口时,它显示如下:

在此输入图像描述

我尝试使用此解决方案存在隐藏状态栏UIImagePickerController:

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

并显示状态条形码ViewWillApear.

我得到了这种结果:

在此输入图像描述

我在哪里做错了,我该如何解决这个问题?

iPa*_*tel 0

尝试UIImagePickerController通过以下方式呈现:

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
[tempWindow.rootViewController presentViewController:myImgPickerController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我不知道它是否对你有帮助,但你也许可以尝试一下......:)

另一种选择是当您演示时UIImagePickerController。当时将视图的框架设置为最初的样子,并隐藏状态栏......