用户与iAd Swift交互时暂停游戏

时间:2015-12-27 22:25:27

标签: ios swift sprite-kit swift2 iad

我目前不了解下面链接问题的已批准解决方案:

  

使用UITapGestureRecognizer代替。检查Recognizer.view!= adBanner

Detect and ignore touches on iAd banners

我在Sprite Kit游戏中遇到了同样的问题,但是在Swift中,我不确定如何实施已批准的解决方案。有人可以提供代码示例吗?

这是我的代码:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for touch in touches {
        // If iAd banner has been tapped, do not start the game

        // Else game starts
    }
}

func adStopsGame(tapGesture: UITapGestureRecognizer) {
    print("Game stopped")
}

1 个答案:

答案 0 :(得分:1)

您需要使用bannerViewActionShouldBegin(_:willLeaveApplication:)

  

当用户点击横幅视图时,将调用此方法。您的   应用程序控制是否触发操作。允许的   要触发的动作,返回true。要取消操作,请返回   假。您的应用程序几乎总是允许操作   触发;阻止行为可能会改变你的广告   应用程序看到并减少您的应用程序所获得的收入   iAd的。

有关ADBannerView委托方法的完整列表,请参阅:ADBannerViewDelegate Protocol Reference