gpt4 book ai didi

ios - GAD adLoader 委托(delegate)未被调用

转载 作者:行者123 更新时间:2023-12-05 09:03:46 24 4
gpt4 key购买 nike

我正在尝试实现原生广告,但没有调用 adLoader 委托(delegate)。更有趣的是,由于某种原因,委托(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)
}
}

最佳答案

发现问题.. 对于将来遇到相同问题的任何人,正确的委托(delegate)是 GADNativeAdLoaderDelegate 而不是 GADNativeAdDelegate 或 GADAdLoaderDelegate

关于ios - GAD adLoader 委托(delegate)未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69505222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com