iOS 8:状态栏不能与UIImagePickerController一起使用

时间:2014-12-10 08:57:36

标签: ios objective-c iphone xcode

我有一个UIImagePickerController的视图..

在整个申请中我有:

/* white color */
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

但是在这种情况下我需要查看状态栏黑色,所以我设置它:

/* black color */ 
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

我在委托

中这样做了
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

但似乎无视指示。

仅适用于iOS< 8.我已经阅读过this个问题,但我无法使其发挥作用。

3 个答案:

答案 0 :(得分:0)

如果您想更改特定视图,请从xib / storyboad更改。

enter image description here

答案 1 :(得分:0)

在呈现UIImagePickerViewController时尝试这样:

[self presentViewController:imagePickerController animated:YES completion:^{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}];

答案 2 :(得分:0)

我以这种方式解决了我的问题:

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

if(IS_IOS8_AND_UP) {
    imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
} else {
    imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
}

imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];

然后在委托中设置默认状态栏样式。

希望这有帮助!