我正在尝试在我的 Flutter 插件中显示来自 Swift 原生代码的 Adcolony 广告,这就是我的 swift 代码的样子 -
if let interstitial = self.interstitial, !interstitial.expired, let
rootViewController = UIApplication.shared.keyWindow?.rootViewController
{
interstitial.show(withPresenting: rootViewController)
}
我的代码运行完美,但我的 View Controller 从不显示插页式广告。任何人都可以帮助我,因为我不知道应该传递哪个 View Controller 来显示我的广告。文档说要使用 self
但我的插件不是 View Controller 所以它不起作用。
最佳答案
试试这个:
if let vc = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController {
interstitial.show(withPresenting: vc)
}
关于ios - 我应该为 Flutter 插件传入我的 Swift native 代码中的哪个 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62175368/