ios - GAD adLoader 代表没有被调用
问题描述
我正在尝试实施原生广告,但没有调用 adLoader 代表。更有趣的是,由于某种原因,delegate 变成了 prints 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)
}
}
解决方案
发现了问题.. 对于将来遇到相同问题的任何人,正确的代表是 GADNativeAdLoaderDelegate 而不是 GADNativeAdDelegate 或 GADAdLoaderDelegate
推荐阅读
- javascript - NodeJS - 如何从 blob 下载?
- python - PCA 显示低解释方差分数
- typo3 - 在 TYPO3 中制作联系表格时在哪里可以找到表格选项卡
- javascript - 如何“正确”检测使用 Javascript 的 WEBP 图像的 mime 类型
- windows - 在本地网络上查看 html 文件
- python - 如何找到“FileNotFoundError”的解决方案
- angular - `breadcrumb` - 累积,而不是在移出页面时重置
- excel-formula - 如何根据另一列的数据在另一列中添加规则
- ubuntu - 静态 html 文件上的 Nginx 404
- google-sheets - 当 F7 和 I7 给定时间时,如果 A 和 B 之间的时间显示 X