关于ios:wkwebview横屏播放后状态栏异常问题解决

3次阅读

共计 633 个字符,预计需要花费 2 分钟才能阅读完成。

WkWebview 横屏全屏播放当前,回到竖屏状态会导致状态栏异样。与这个问题相似:https://stackoverflow.com/que…

解决方案也是如此。写下 oc 的解决办法:

// 横屏状态下暗藏状态栏,保障视频能够全屏播放
- (BOOL)prefersStatusBarHidden {return UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft || UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight;}
// 放到 viewDidLoad 办法外面监听屏幕的变动
[[NSNotificationCenter defaultCenter] addObserver:self
                                                     selector:@selector(handleDeviceOrientationDidChange)
                                                         name:UIDeviceOrientationDidChangeNotification
                                                       object:nil];
// 刷新 statusbar 的暗藏状态,当屏幕地位发生变化的时候
- (void)handleDeviceOrientationDidChange {[self setNeedsStatusBarAppearanceUpdate];
}
正文完
 0