在swift和spritekit中的横向显示iAd横幅

首先我通过堆栈溢出了几个小时,没有任何类似的主题适用于我试图做的事情。

我有iads显示,但它的纵向模式显示iad的大小,不知何故,我需要一个适用于景观,这里是我有的代码,我已经改变了数字,并与代码搞砸了,但它只是不会为我工作。

这段代码在我的gameviewcontroller中:

var SH = UIScreen.mainScreen().bounds.height let transition = SKTransition.fadeWithDuration(1) var UIiAd: ADBannerView = ADBannerView() override func viewWillAppear(animated: Bool) { var BV = UIiAd.bounds.height UIiAd.delegate = self UIiAd.frame = CGRectMake(0, SH + BV, 0, 0) self.view.addSubview(UIiAd) } override func viewWillDisappear(animated: Bool) { UIiAd.delegate = nil UIiAd.removeFromSuperview() } func bannerViewDidLoadAd(banner: ADBannerView!) { var BV = UIiAd.bounds.height UIView.beginAnimations(nil, context: nil) UIView.setAnimationDuration(0) // Time it takes the animation to complete UIiAd.alpha = 1 // Fade in the animation UIView.commitAnimations() } func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) { UIView.beginAnimations(nil, context: nil) UIView.setAnimationDuration(0) UIiAd.alpha = 0 UIView.commitAnimations() } func showBannerAd() { UIiAd.hidden = false var BV = UIiAd.bounds.height UIView.beginAnimations(nil, context: nil) UIView.setAnimationDuration(0) // Time it takes the animation to complete UIiAd.frame = CGRectMake(0, SH - BV, 0, 0) // End position of the animation UIView.commitAnimations() } func hideBannerAd() { UIiAd.hidden = true var BV = UIiAd.bounds.height UIView.beginAnimations(nil, context: nil) UIView.setAnimationDuration(0) // Time it takes the animation to complete UIiAd.frame = CGRectMake(0, SH + BV, 0, 0) // End position of the animation UIView.commitAnimations() } 

我附上了一个屏幕截图,以显示我遇到的问题,如果有人能帮助它将是伟大的!

iad风景问题

谢谢。

试试这个,告诉我它的工作。

  let screenBounds: CGRect = UIScreen.mainScreen().bounds var adBannerView: ADBannerView 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)