I was wondering if someone can help me with this. I am trying to create a iAd banner in landscape mode. So far I used this code. It still shows the iAd banner with the same height and width as if it was displayed in a portrait mode. The banner is centered though. Any help would be much appreciated.
var adBannerView: ADBannerView!
let screenBounds: CGRect = UIScreen.mainScreen().bounds
override func viewDidLoad() {
super.viewDidLoad()
// Presenting scene without using GameScene.sks
let skView = self.view as SKView
let myScene = Menu(size: skView.frame.size)
skView.presentScene(myScene)
loadAds()
print("height: \(screenBounds.height), width: \(screenBounds.width)")
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
println("Leaving app to the Ad")
return true
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height - adBannerView.frame.size.height / 2)
adBannerView.frame = CGRectOffset(adBannerView.frame,0.0,0.0)
adBannerView.hidden = false
println("Displaying the Ad")
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height + view.bounds.size.height)
println("Ad is not available")
}
func loadAds() {
adBannerView = ADBannerView(frame: CGRectMake(0, 0, 50, screenBounds.width))
adBannerView.center = CGPoint(x: screenBounds.width/2, y: screenBounds.height-adBannerView.frame.height)
adBannerView.delegate = self
adBannerView.hidden = true
view.addSubview(adBannerView)
}