1. 程式人生 > >iOS12 在h5頁面內播放視訊後狀態列丟失

iOS12 在h5頁面內播放視訊後狀態列丟失

問題描述:

使用web播放視訊後 狀態列丟失 或者 使用web播放視訊後頁面上移 20

解決辦法:

#pragma mark  --通知
-(void)addObserverNotification{
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(windowDidBecomeHidden:) name:UIWindowDidBecomeHiddenNotification object:nil];
}

-(void)windowDidBecomeHidden:(NSNotification *)noti{
    
    UIWindow * win = (UIWindow *)noti.object;
    
    if(win){
        
        UIViewController *rootVC = win.rootViewController;
        
        NSArray<__kindof UIViewController *> *vcs = rootVC.childViewControllers;
        
        if([vcs.firstObject isKindOfClass:NSClassFromString(@"AVPlayerViewController")]){
            
            [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
        }
    }
}