iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status

Posted 努力搬砖的码农

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status相关的知识,希望对你有一定的参考价值。

突然的崩溃让我措手不及

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

             }

}

以上是关于iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status的主要内容,如果未能解决你的问题,请参考以下文章

在 UIApplication 上调用 -statusBar 或 -statusBarWindow 的应用程序

如何在 iOS 13 中更改状态栏 Alpha?

iOS 设置状态栏的背景颜色

Ionic Capacitor Deploy App on ios 13.3 device freeze splashscreen

Exceptions and Errors on iOS

iOS 14 UICollectionView新功能之TableView