ios - 线程 1 : signal SIGABRT error running on Xcode 11. 2.1

标签 ios react-native react-native-ios xcode11 xcode11.2.1

项目(react-native)在 ​​Xcode 10.2 上运行良好,为了在 iOS 13 上测试它,我尝试用 Xcode 11.2.1 打开项目,应用程序在启动时崩溃,Xcode 11.2.1 出现错误控制台如下:

Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.16/UIApplication.m:5316
2019-12-10 14:26:37.206842+0530 workish[73259:574909] *** 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.'
*** First throw call stack:

最佳答案

您正在尝试访问自 iOS 13 以来已弃用的代码中某处的 statusBar。以下是获取 iOS 13+ 及以下版本的 statusBar 的示例代码

  if #available(iOS 13.0, *) {
    let statusBarFrame = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)
     statusBarFrame.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
     UIApplication.shared.keyWindow?.addSubview(statusBarFrame)
} else {
     UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
}

关于ios - 线程 1 : signal SIGABRT error running on Xcode 11. 2.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59263516/

相关文章:

iphone - 如何在通用应用程序中同时支持 iPad 和 iPhone 视网膜图形

ios - 构造函数不能快速工作

javascript - 在 TabBar 中移动选项卡时,组件生命周期 (ComponentDidMount) 不起作用?

ios - 在另一个 UIViewController init 中初始化自定义 UIViewController

ios - APNS 推送通知不适用于生产

reactjs - 如何在 React Native 中为推送通知添加点击操作

javascript - React Native 中的 Object.keys 顺序

ios - 如何更改expo React-Native中的ipa版本

react-native - react : Calling JS function after bridge has been destroyed --- How to find which function

react-native-ios - 世博XDE "timeout of 60000 ms exceeded"?