【发布时间】:2015-12-27 22:25:26
【问题描述】:
我目前不明白下面链接的问题的批准解决方案:
改为使用 UITapGestureRecognizer。检查是否识别器.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")
}
【问题讨论】:
-
如果允许的话,我会非常小心。如果某些用户看到有趣的东西,iAd 可以触摸它 - 如果您禁用触摸它的功能,这可能很容易与苹果 iAd ToS 冲突
-
我不想阻止用户使用广告,只是在他们查看广告时阻止游戏在后台运行。
-
啊,好吧,这是非常合理的要求,您可能需要更改问题标题以更好地反映这一点,例如“用户观看 iAd 时暂停游戏”
-
有一个 iAD 委托方法,您使用
bannerViewActionShouldBegin:willLeaveApplication:在此方法中,您暂停游戏,但触摸不应从 iAd 视图向下移动到游戏场景,如果它是,那么您的视图设置不正确 -
那行,谢谢
标签: ios swift sprite-kit swift2 iad