相关疑难解决方法(0)

在 SwiftUI 中显示“UIActivityViewController”

我想让用户能够共享位置,但我不知道如何UIActivityViewController在 SwiftUI 中显示。

uiactivityviewcontroller swiftui xcode11

38
推荐指数
7
解决办法
1万
查看次数

如何使用 AdMob 横幅消除消息“'windows' 在 iOS 15.0 中已弃用:在相关窗口场景上使用 UIWindowScene.windows”?

我想摆脱我的函数中的“‘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)

谢谢

admob rootviewcontroller swiftui uiwindowscene

5
推荐指数
1
解决办法
8034
查看次数