iOS9以上系統(tǒng)橫屏播放UIWebView中的視頻返回后會(huì)出現(xiàn)以下問(wèn)題:
1、如圖,UIWebView中包含一個(gè)視頻:

1
2、播放web內(nèi)容中的視頻,并橫屏觀看:

2
3、直接在橫屏狀態(tài)下返回,會(huì)出現(xiàn)狀態(tài)欄蓋在導(dǎo)航欄上面,導(dǎo)航欄位置錯(cuò)誤的問(wèn)題:

3
解決方法:
參照navigation bar under status bar after video playback in landscape mode的解決方法,Objective-C代碼如下:
1、重載prefersStatusBarHidden方法:
- (BOOL)prefersStatusBarHidden {
return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
}
2、監(jiān)聽屏幕旋轉(zhuǎn):
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoDidRotate) name:UIDeviceOrientationDidChangeNotification object:nil];
}
3、調(diào)用setNeedsStatusBarAppearanceUpdate:
- (void)videoDidRotate {
[self setNeedsStatusBarAppearanceUpdate];
}
4、記得移除監(jiān)聽事件。