swift iad banner not working

my iad banner can't work. my project use objective c + swift.

always error message : ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "The operation couldn’t be completed. Ad was unloaded from this banner" UserInfo=0x7fb6e16b70e0 {ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}


when i change UIView (in BannerAds) to UIViewController and show UIViewController, The fully working correctly. but use UIView I get the error message.


my code in swift :



import UIKit

import iAd

import GoogleMobileAds

/

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

/

}


func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!){

println("\n didFailToReceiveAdWithErrorüüüü ",error)

iAdBanner.hidden = true

/

}



}




this my main objective 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];

Answered by joshk in 13237022

Ursan-


Your delegate must implement the bannerView:didFailToReceiveAdWithError: callback to handle scenarios in which the banner view fails to load a new ad. Please see:


https://developer.apple.com/library/ios/documentation/UserExperience/Reference/ADBannerViewDelegate_Ref/index.html#//apple_ref/occ/intfm/ADBannerViewDelegate/bannerView:didFailToReceiveAdWithError:


-Josh

Accepted Answer

Ursan-


Your delegate must implement the bannerView:didFailToReceiveAdWithError: callback to handle scenarios in which the banner view fails to load a new ad. Please see:


https://developer.apple.com/library/ios/documentation/UserExperience/Reference/ADBannerViewDelegate_Ref/index.html#//apple_ref/occ/intfm/ADBannerViewDelegate/bannerView:didFailToReceiveAdWithError:


-Josh

swift iad banner not working
 
 
Q