我的iad横幅无法正常工作。我的项目使用目标c + swift。
始终出现错误消息:ADBannerView:未处理的错误(没有委托或委托未实现didFailToReceiveAdWithError :):错误域= ADErrorDomain代码= 7"操作无法完成。广告已从此横幅广告中删除" UserInfo = 0x7fb6e16b70e0 {ADInternalErrorCode = 7,NSLocalizedFailureReason = Ad已从此横幅卸载,ADInternalErrorDomain = ADErrorDomain}
当我将UIView(在BannerAds中)更改为UIViewController并显示UIViewController时,完全正常工作。但是使用UIView我收到错误信息。
我在swift中的代码:
import UIKit
import iAd
import GoogleMobileAds
//import Foundation
class BannerAds: UIView,ADBannerViewDelegate {
var iAdBanner : ADBannerView!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
}
override init (frame : CGRect) {
super.init(frame : frame)
self.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleRightMargin
self.backgroundColor = UIColor.clearColor()
iAdEkle()
}
func iAdEkle() {
iAdBanner = ADBannerView(frame: CGRectMake(0, 0, 320, 50))
self.addSubview(iAdBanner)
iAdBanner.delegate = self
}
func bannerViewDidLoadAd(banner: ADBannerView!)
{
println("bannerViewDidLoadAd")
iAdBanner.hidden = false
//self.addSubview(iAdBanner)
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!){
println("\n didFailToReceiveAdWithErrorüüüü ",error)
iAdBanner.hidden = true
// siradakiniEkle(adList.iAd)
}
}
这是我的主要目标c:
float ysi = self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.bounds.size.height - 55;
CGRect frame = CGRectMake(0, 222, self.tabBarController.view.bounds.size.width, 55);
BannerAds *banner = [[BannerAds alloc] initWithFrame:frame];
[self.tabBarController.view insertSubview:banner belowSubview:self.tabBarController.tabBar];