簡體   English   中英

iOS 8:狀態欄不適用於UIImagePickerController

[英]iOS 8: status bar doesn't work with UIImagePickerController

我有一個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。我已經閱讀了問題和其他內容,但無法使其正常工作。

如果要更改特定的查看方式,只需從xib / storyboad進行更改。

在此處輸入圖片說明

在呈現UIImagePickerViewController時嘗試這樣:

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

我以這種方式解決了我的問題:

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];

然后在委托中設置默認狀態欄樣式。

希望對您有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM