我应该为 Flutter 插件传入 Swift 本机代码中的哪个视图控制器?
Which view controller should I pass in my Swift native code for a Flutter plugin?
我正在尝试在我的 Flutter 插件中显示来自 Swift 本机代码的 Adcolony 广告,这就是我的 swift 代码的样子 -
if let interstitial = self.interstitial, !interstitial.expired, let
rootViewController = UIApplication.shared.keyWindow?.rootViewController
{
interstitial.show(withPresenting: rootViewController)
}
我的代码运行完美,但我的视图控制器从不显示插页式广告。任何人都可以帮助我,因为我不知道应该传递哪个视图控制器来显示我的广告。文档说要使用 self
但我的插件不是视图控制器所以它不起作用。
试试这个:
if let vc = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController {
interstitial.show(withPresenting: vc)
}
我正在尝试在我的 Flutter 插件中显示来自 Swift 本机代码的 Adcolony 广告,这就是我的 swift 代码的样子 -
if let interstitial = self.interstitial, !interstitial.expired, let
rootViewController = UIApplication.shared.keyWindow?.rootViewController
{
interstitial.show(withPresenting: rootViewController)
}
我的代码运行完美,但我的视图控制器从不显示插页式广告。任何人都可以帮助我,因为我不知道应该传递哪个视图控制器来显示我的广告。文档说要使用 self
但我的插件不是视图控制器所以它不起作用。
试试这个:
if let vc = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController {
interstitial.show(withPresenting: vc)
}