iAd banner更改了我的SKScene的frame.size

时间:2015-04-16 12:56:37

标签: ios ipad sprite-kit adbannerview

用户第一次点击iAd横幅时,它会正确显示,然后返回我的游戏。 第二次点击实际上使广告的行为就像横向模式一样: 所以视图的右侧与平板电脑的真实右侧对齐,由节点和fps"判断。指示符。 但视图的尺寸现在是1024 * 768而不是768 * 1024。

因此,场景的中心几乎位于iPad的左边缘!

我尝试在bannerAds的委托中以编程方式更改它,但没有成功。实际上,尺寸值实际上会改变,但不是我的屏幕!

var currentOrientation:UIDeviceOrientation=UIDeviceOrientation.Portrait
var oldFrameSize:CGSize?

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

    //pause game here

    currentOrientation=UIDevice.currentDevice().orientation

    oldFrameSize=self.frame.size
    println("Leave the application to the Ad")

    return true
}

func bannerViewActionDidFinish(banner: ADBannerView!) {

    UIDevice.currentDevice().setValue(currentOrientation.rawValue, forKey: "orientation")

    switch(currentOrientation){
    case UIDeviceOrientation.Portrait:
        self.view?.window?.rootViewController?.setValue(UIInterfaceOrientation.Portrait.rawValue, forKey: "interfaceOrientation")
        break
    case UIDeviceOrientation.PortraitUpsideDown:
        self.view?.window?.rootViewController?.setValue(UIInterfaceOrientation.PortraitUpsideDown.rawValue, forKey: "interfaceOrientation")
        break
    default: break;
    }


    self.size=oldFrameSize!

    self.view?.clipsToBounds=true
    println(frame.size.width)
    println(oldFrameSize!.width)
    println(size.width)


    println("Close the Ad")

}

编辑:以下是第一个广告显示和第二个广告显示之间差异的快照:

First Ad

Second Ad

0 个答案:

没有答案