我有这段代码:
class ViewControllergame: UIViewController, ADBannerViewDelegate {
var bannerView:ADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
self.canDisplayBannerAds = true
bannerView?.delegate = self
bannerView?.hidden = true
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
bannerView?.hidden = false
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return willLeave
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
bannerView?.hidden = true
}
}
但它不在didFailToReceiveAdWithError中,当我的应用程序进入待机状态时,我收到此错误:
ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=1 "Service session terminated.
我该如何解决这个问题?
答案 0 :(得分:2)
您似乎已经实施了这些方法,但由于未设置横幅广告代码,因此从未调用过这些方法。如果您正在使用故事板
控制-将
从您的ADBannerView到横幅所在的ViewController,然后选择"委托"出口。