UIImagePickerController presentViewController - ios7中的状态栏问题

时间:2013-10-11 13:32:14

标签: iphone ios7 uiimagepickercontroller statusbar

我在iOS 7中面临状态栏问题。 enter image description here

以下是展示此图片选择器的代码

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

        picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;

        if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
            [self presentViewController:picker animated:YES completion:^{

                if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
                    [[UIApplication sharedApplication] setStatusBarHidden:YES
                                                            withAnimation:UIStatusBarAnimationNone];
            }];
        }
        else {
            [self presentModalViewController:picker animated:YES];
        }
    }

当我尝试选择图像时,屏幕如下所示

enter image description here

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:6)

试试这个

- (void)imagePickerController:(UIImagePickerController *)aPicker didFinishPickingMediaWithInfo:(NSDictionary *)info {

// for iOS7
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {

    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

编辑:

这是一个更容易的解决方案。

在plist中添加基于布尔视图控制器的状态栏外观,并将其值设置为NO。然后在您的app appate application didFinishLaunchingWithOptions中声明以下内容:

[application setStatusBarHidden:NO];
[application setStatusBarStyle:UIStatusBarStyleDefault];

启动相机时应该处理状态栏。然后对于相机胶卷部件,只需在视图控制器中添加以下方法,即已放置UIImagePickerController的代码

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

选择相机胶卷时应该注意模态视图状态栏。

希望这有助于帮助人。