0

The error and the problem:

WARNING: More than 10 instances of ADBannerView or ADInterstitialView currently exist. This is a misuse of the iAd API, and ad performance will suffer as a result. This message is printed only once.

my implementation of the adView:

var adView = ADBannerView()
override func viewDidLoad() {
    super.viewDidLoad() 
    adView.frame = CGRectOffset(adView.frame, 0, self.view.bounds.height - adView.bounds.height)
    adView.sizeToFit()
    self.view .addSubview(adView)

    adView.alpha = 0.001
    adView.delegate = self

    }

i have looked on the internet and i found that i need to implement the "viewWillDisappear" and i did so:

my first try:

override func viewWillDisappear(animated: Bool) {

    adView.removeFromSuperview()
    adView.delegate = nil
}

and the second:

override func viewWillDisappear(animated: Bool) {
    for view in self.view.subviews {
        view.removeFromSuperview()
    }

    adView.removeFromSuperview()
    adView.delegate = nil
}

one more thing, it says that it will just be displayed once but i get the error every time i run the app on my phone

reojased
  • 709
  • 1
  • 7
  • 19
  • 1
    You should show the code where you are *adding* your `adView` in this question. You should be using one single adview in your view controller, not re-creating it over and over again. – Michael Dautermann Dec 28 '14 at 06:16
  • Thank you i'll post that part of my code as soon as possible – reojased Jan 01 '15 at 23:44

1 Answers1

0

After some search i came to this solution :

    let adView = ADBannerView()

override func viewDidLoad() {
    super.viewDidLoad()

adView.frame = CGRectOffset(adView.frame, 0, self.view.bounds.height - adView.bounds.height)
    adView.sizeToFit()
    adView.alpha = 0.001
    adView.delegate = self
    self.view .addSubview(adView)

    self.canDisplayBannerAds = true
    }


override func viewWillDisappear(animated: Bool) {
    for view in self.view.subviews {
        view.removeFromSuperview()
    }

    adView.hidden = true
    adView.delegate = nil

    adView.removeFromSuperview()
}

apparently I missed to add the "self.canDisplayBannerAds = true" and that fixed the problem for now

reojased
  • 709
  • 1
  • 7
  • 19