snk*_*snk 2 delegates admob ios swift
我正在尝试实施原生广告,但 adLoader 委托不会被调用。更有趣的是,委托由于某种原因变成了 nil。没有打印错误,没有收到。任何意见是极大的赞赏。
func getAd(){
let adLoader = GADAdLoader(adUnitID: adUnitID, rootViewController: self, adTypes: [.native], options: [options])
adLoader.delegate = self
print(adLoader.delegate)
adLoader.load(GADRequest())
}
extension ViewController:GADNativeAdDelegate, GADAdLoaderDelegate{
func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADNativeAd) {
print("did receive")
// A native ad has loaded, and can be displayed.
}
func adLoaderDidFinishLoading(_ adLoader: GADAdLoader) {
print("finish Loading")
// The adLoader has finished loading ads, and a new request can be sent.
}
func adLoader(_ adLoader: GADAdLoader, didFailToReceiveAdWithError error: Error) {
print(error)
}
}
Run Code Online (Sandbox Code Playgroud)
发现问题..对于将来遇到相同问题的任何人,正确的委托是 GADNativeAdLoaderDelegate 而不是 GADNativeAdDelegate 也不是 GADAdLoaderDelegate
| 归档时间: |
|
| 查看次数: |
725 次 |
| 最近记录: |