iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window 错误

突然的崩溃让我措手不及

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'

修改方式

  if (@available(iOS 13.0, *)) {

             if (!_statusBar) {

                 // iOS 13  弃用keyWindow属性  从所有windowl数组中取

                 UIWindow *keyWindow = [UIApplication sharedApplication].windows[0];

                 _statusBar = [[UIView alloc] initWithFrame:keyWindow.windowScene.statusBarManager.statusBarFrame];

                 [keyWindow addSubview:_statusBar];

             }

}

猜你喜欢

转载自www.cnblogs.com/yangqinoak/p/11896798.html
今日推荐