这里插入代码

问题报错:‘windowswas deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

let keyWindow:UIWindow = {
if #available(iOS 13.0, *) {
return UIApplication.shared.windows.filter({ $0.isKeyWindow }).last!
}else {
return UIApplication.shared.keyWindow!
}
}()

更改

let keyWindow : UIWindow? = {
if #available(iOS 13.0, *) {
return UIApplication.shared.connectedScenes.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }.first?.windows
.filter { $0.isKeyWindow }.first;
}else {
return UIApplication.shared.keyWindow!
}
}()

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注