【发布时间】:2022-01-14 15:32:24
【问题描述】:
我正在使用通过按钮触发的以下代码在我的应用中显示共享表:
func shareSheet() {
guard let urlShare = URL(string: "https://google.com") else { return }
let activityVC = UIActivityViewController(activityItems: [urlShare], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(activityVC, animated: true, completion: nil)
}
此代码引发警告:
'windows' 在 iOS 15.0 中已弃用:在相关窗口场景上使用 UIWindowScene.windows 代替
我不明白如何才能摆脱它。已经检查了这里建议的方法How to get rid of message " 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead" with AdMob banner?,但它不起作用。有什么想法可以绕过警告吗?
非常感谢!
【问题讨论】:
标签: swiftui deprecated deprecation-warning ios-sharesheet