【发布时间】:2021-10-09 09:01:56
【问题描述】:
我正在尝试实施原生广告,但没有调用 adLoader 代表。更有趣的是,由于某种原因,delegate 变成了 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)
}
}
【问题讨论】:
-
在哪里声明委托并创建对象?
-
@RajaKishan adLoader 在自定义函数中.. 刚刚更新了编码