为什么我的插页式广告会产生错误?

时间:2017-10-01 14:30:36

标签: swift sprite-kit admob google-admob

我试图在显示场景游戏时显示插页式广告,而我只是出错了。我搜索了答案,但他们产生了相同的结果。我正在使用通知中心方法,但它无法正常工作。我的横幅视图工作得很好。

我收到此错误:

  

CoreAnimation:[EAGLContext renderbufferStorage:fromDrawable:]   在隐式事务中从非主线程调用!注意   如果没有明确的CATransaction或调用,这可能是不安全的   [CATransaction flush]。 2017-10-01 09:28:00.631015-0500   Split [868:273850] CoreAnimation:[EAGLContext   renderbufferStorage:fromDrawable:]是从非主线程调用的   在一个隐含的交易中!请注意,如果没有,这可能是不安全的   显式CATransaction或调用[CATransaction flush]。

override func viewDidLoad() {
    super.viewDidLoad()


    NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.loadAndShow), name: NSNotification.Name(rawValue: "loadAndShow"), object: nil)

    let request = GADRequest()

    request.testDevices = [kGADSimulatorID, "49d92844bdbdf74dac25e343b377744f"]

    bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)

    self.view?.addSubview(bannerView)
    bannerView.adUnitID = "ca-app-pub-9408273734198014/6590781864"

    bannerView.rootViewController = self
    bannerView.load(GADRequest())

    bannerView.delegate = self

    interstitialView = GADInterstitial(adUnitID: "ca-app-pub-9408273734198014/7472368678")

    interstitialView.load(request)

    if let view = self.view as! SKView? {
        // Load the SKScene from 'GameScene.sks'
        if let scene = SKScene(fileNamed: "StartScene") {
            // Set the scale mode to scale to fit the window
            scene.scaleMode = .aspectFill

            // Present the scene
            view.presentScene(scene)

        }



        view.ignoresSiblingOrder = true

        view.showsFPS = true
        view.showsNodeCount = true


    }


}


@objc func loadAndShow() {

    interstitialView = GADInterstitial()
    let request = GADRequest()
    interstitialView.setAdUnitID("ca-app-pub-9408273734198014/7472368678")
    interstitialView.delegate = self
    interstitialView.load(request)


}


func showInterstitial(ad: GADInterstitial!) {

    if (self.interstitialView.isReady) {

        interstitialView.present(fromRootViewController: self)

    }

}

0 个答案:

没有答案