Search code examples
iosswiftbanner-adsfacebook-audience-network

Why are my facebook banner ads too small for the ipad in Swift Spritekit?


The banner ads fit perfectly on the bottom of the screen for the 4s, 5 and 5s but for the iPad, and iPhone 6 and 6 + there too small. What am I doing wrong? I put this code in the GameViewController.swift fie. If you need more info please let me know. Thank you!

let adView: FBAdView = FBAdView(placementID:"PLACEMENT_ID",   
adSize:kFBAdSize320x50, rootViewController:self)
adView.frame = CGRect(x: 0, y: self.view.frame.size.height - 50, width: 320, height: 90)
    self.view.addSubview(adView)
    adView.delegate = self
    FBAdSettings.addTestDevice("TESTDEVICE")
    adView.loadAd()

Solution

  • You should work with percentage-sizes:

    var theWidth = self.frame.width
    var theHeight = self.frame.height / 15 //for example. But make the height as you need
    

    Instead of hard coded sizes like you did. Then you can use your size like that:

    adView.frame = CGRect(x: 0, y: self.view.frame.size.height - 50, width: theWidth, height: theHeight)