最近做的一個項目,在調用相機返回后狀態欄消失了,與之前一個項目對比,沒有什么差別,但是就是會這樣,找了很久原因無果,只好用下面的方法先做了,但我覺得本質還是項目設置的問題,忘大神看到了指點一二。
暫時用的方法:
1:在項目調用相機的ViewController里重寫preferredStatusBarStyle方法。
-(UIStatusBarStyle)preferredStatusBarStyle
{
returnUIStatusBarStyleDefault;
}
2:在相機返回的地方調用[selfsetNeedsStatusBarAppearanceUpdate];
-(void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
{
[picker dismissViewControllerAnimated:YEScompletion:^{
[self setNeedsStatusBarAppearanceUpdate];
}];
}
以上設置我是在ios10.3的手機上測試的。
ps:終于找到根本原因了,我用了一個庫,庫里面有寫一個UINavigationController的category
里面重寫了兩個方法:
- (UIViewController*)childViewControllerForStatusBarStyle {
returnself.visibleViewController;
}
- (UIViewController*)childViewControllerForStatusBarHidden {
returnself.visibleViewController;
}
把這兩個去掉就正常了,具體是什么原理還在思考中,大神路過的話指點一下。·