我想让用户能够共享位置,但我不知道如何UIActivityViewController
在 SwiftUI 中显示。
我想摆脱我的函数中的“‘windows’在 iOS 15.0 中已弃用:在相关窗口场景上使用 UIWindowScene.windows”消息(顺便说一下,我的函数运行得很好。)。
涉及的代码行:
banner.rootViewController = UIApplication.shared.windows.first?.rootViewController
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我的职能:
struct AdView : UIViewRepresentable {
func makeUIView(context: UIViewRepresentableContext<AdView>) -> GADBannerView {
let banner = GADBannerView(adSize: kGADAdSizeBanner)
banner.adUnitID = "ca-app-pub-3940256099942544/2934735716" // test ad
banner.rootViewController = UIApplication.shared.windows.first?.rootViewController
banner.load(GADRequest())
return banner
}
func updateUIView(_ uiView: GADBannerView, context: UIViewRepresentableContext<AdView>) {}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过,但它不起作用:
banner.rootViewController = UIApplication.shared.connectedScenes.first?.rootViewController
Run Code Online (Sandbox Code Playgroud)
谢谢