wkwebview横屏播放后,状态栏异常问题解决

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

你可能感兴趣的:(ios)