我正在尝试使用 Xcode 11 beta 6 和 iOS 13 beta 8 构建我的应用程序,但一旦开始运行就会抛出此错误:
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.'
什么是窗口场景以及如何使用 statusBarManager
?
我不确定这是否相关,但我没有使用任何 SwiftUI
。
最佳答案
您需要添加以下扩展才能访问 statusbarview :
extension UIApplication {
var statusBarUIView: UIView? {
if #available(iOS 13.0, *) {
let tag = 38482458385
if let statusBar = self.keyWindow?.viewWithTag(tag) {
return statusBar
} else {
let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame)
statusBarView.tag = tag
self.keyWindow?.addSubview(statusBarView)
return statusBarView
}
} else {
if responds(to: Selector(("statusBar"))) {
return value(forKey: "statusBar") as? UIView
}
}
return nil
}
}
关于ios - UIApplication 上名为 -statusBar 或 -statusBarWindow 的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57801484/