赞
踩
iOS 12 H5视频播放进入全屏的时候 返回会有一个状态栏丢失问题
//添加通知
if (@available(iOS 12.0, *)) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeHidden:) name:UIWindowDidBecomeHiddenNotification object:nil];
}
#pragma mark - notification event - (void)windowDidBecomeHidden:(NSNotification *)notification { //iOS 12 H5视频播放进入全屏的时候 返回会有一个状态栏丢失问题 这里监听通知解决一下 UIWindow *window = (UIWindow *)notification.object; if(!window){ return ; } UIViewController *rootVC = window.rootViewController; NSArray<__kindof UIViewController *> *vcs = rootVC.childViewControllers; if([vcs.firstObject isKindOfClass:NSClassFromString(@"AVPlayerViewController")]){ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade]; #pragma clang diagnostic pop } }
dealloc的时候移除通知
if (@available(iOS 12.0, *)) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIWindowDidBecomeHiddenNotification object:nil];
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。