1

I am working on an app and would like to include iAd's. I have managed to add banner ad's and they work well. However i want to a larger add that fills most of the screen but not full screen. I added the adBanner using code from Benzene's Question and given solution from erdekhayser.

Apple iAd Documentation (Page 3)

The link i have referenced above is from the apple documentation and apple refer to the iAd as an MREC ad. This is what i would like to have. I cannot work out how to create and add one though. I have tried resizing the adBanner but still cannot figure it out.

Any help would be appreciated

This is the code i have so far:

import UIKit
import SpriteKit
import iAd
import Twitter

var adBannerView: ADBannerView!

class GameViewController: UIViewController, ADBannerViewDelegate {

var scene: GameScene!

func loadAds() {

    adBannerView = ADBannerView(frame: CGRectZero)
    adBannerView.delegate = self
    adBannerView.hidden = true
    view.addSubview(adBannerView)
}

override func viewDidLoad() {
    super.viewDidLoad()

        // Configure the view.
        let skView = view as SKView
        skView.showsFPS = false
        skView.showsNodeCount = true
        skView.showsPhysics = false

        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true

        /* Set the scale mode to scale to fit the window */
        scene = GameScene(size: skView.bounds.size)
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)

        //iAd
        loadAds()



}

//iAd
func bannerViewWillLoadAd(banner: ADBannerView!) {


    println("Ad about to load")

}

func bannerViewDidLoadAd(banner: ADBannerView!) {

    adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height - view.bounds.size.height + adBannerView.frame.size.height / 2)

    adBannerView.hidden = false
    println("Displaying the Ad")

}

func bannerViewActionDidFinish(banner: ADBannerView!) {


    println("Close the Ad")

}

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

    //pause game here


    println("Leave the application to the Ad")
    return true 
}

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

    //move off bounds when add didnt load

    adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height + view.bounds.size.height)

    println("Ad is not available")

}
Community
  • 1
  • 1
PoisonedApps
  • 716
  • 8
  • 21
  • Please show us what code you have thus far – Kyle Decot Oct 19 '14 at 02:43
  • 1
    Have added the code i have so far. Hope you can help – PoisonedApps Oct 20 '14 at 05:36
  • Did you ever get anywhere with this? – TerranceW Jun 18 '15 at 20:30
  • Yeah i switched to google ad's. Much better in my opinion – PoisonedApps Jun 24 '15 at 16:39
  • Ah ok. Is it easier to put GoogleAdSense on your app? Do they pay better? – TerranceW Jun 25 '15 at 05:27
  • Absolutely, they pay better and the fill rate is much better. Campaigning your own ads's is also more flexible. – PoisonedApps Jun 26 '15 at 22:36
  • Interesting, thanks for the info. Is the pay better just because the fill rate is better? I did some research and people said they generally used iAd but used admob to fill in when iAd wasn't serving. Have you experienced both? Is it better to just use admob now? (I wouldn't be surprised if a lot has changed since those articles saying iAd is better were posted) @Nfinity – TerranceW Aug 12 '15 at 08:04
  • Yeah i now use both ad frameworks in my projects. Basically as a fail rate system incase one isn't working etc. The fill rate is better with admob however IAd has become more stable over time. Google pays a little bit more, not by much though. To be honest it doesn't really matter which one you use now, or both if you wish. @TerranceW – PoisonedApps Aug 12 '15 at 17:38

1 Answers1

2

Set canDisplayBannerAds to true.

override func viewDidLoad() {
super.viewDidLoad()

    // Configure the view.
    let skView = self.originalContentView as! SKView

    loadAds()

    self.canDisplayBannerAds = true // <--

    skView.showsFPS = false
    skView.showsNodeCount = true
    skView.showsPhysics = false

    /* Sprite Kit applies additional optimizations to improve rendering performance */
    skView.ignoresSiblingOrder = true

    /* Set the scale mode to scale to fit the window */
    scene = GameScene(size: skView.bounds.size)
    scene.scaleMode = .AspectFill

    skView.presentScene(scene)

}

leoli1
  • 148
  • 6