运行代码时,我会在输出窗口中看到“正在尝试加载广告”,没有其他显示。然后,在10秒钟后,该广告应在该位置展示,但这不是因为未加载广告。我正在用我的密钥测试此代码,但是我什至没有从MoPub管理面板中看到任何请求。我还有一个标签,可以在广告不加载后更改文字,以帮助我调试。
var interstitial: MPInterstitialAdController = MPInterstitialAdController(forAdUnitId: "XXXXXXXXXXXXXXXXXXXX")
override func viewDidLoad() {
self.loadAd()
}
func loadAd(){
//self.interstitial.delegate = self as! MPInterstitialAdControllerDelegate
DispatchQueue.main.async {
self.interstitial.loadAd()
}
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0, execute: {
if(self.interstitial.ready){
self.interstitial.show(from: self)
}
else{
self.errorDebugger.text = "Could not load."
}
})
}