Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

iAd glitch

I am using Swift on Xcode 7.2 and I can't seem to properly instal a code for iAd.


I am trying to install ads on 2 view controllers, but it doesn't seem to work properly. It works fine on the first view controller but on the second view controller, the one with my game, it glitches and restarts the game every time a new ad reloads.


This is the code for the 1st view controller:

importUIKit

import iAd


class ViewController: UIViewController, ADBannerViewDelegate {


@IBOutlet var adBannerView: ADBannerView?


override func viewDidLoad() {

super.viewDidLoad()

//ads

self.canDisplayBannerAds = true

self.adBannerView?.delegate = self

self.adBannerView?.hidden = true

}

//ad func

func bannerViewWillLoadAd(banner: ADBannerView!) {

}

func bannerViewDidLoadAd(banner: ADBannerView!) {

self.adBannerView?.hidden = false

}

func bannerViewActionDidFinish(banner: ADBannerView!) {

}

func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {

returntrue

}

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

self.adBannerView?.hidden = true

}

}

This is the 2nd view controller, Where glitch occurs:

import UIKit

import iAd


class Game: UIViewController, ADBannerViewDelegate {


@IBOutlet var adBannerView: ADBannerView?


override func viewDidLoad() {

super.viewDidLoad()

//ads

self.canDisplayBannerAds = true

self.adBannerView?.delegate = self

self.adBannerView?.hidden = true

}

}

Xcode-OTHER, Swift

Posted on Feb 3, 2016 1:34 PM

Reply

There are no replies.

iAd glitch

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.