swift iad banner not working

229 views Asked by At

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

//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)
    }


}

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];
0

There are 0 answers