OGeek|极客世界-中国程序员成长平台

标题: ios - 某些插页式广告在点击 'X' 时不会关闭或关闭 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:01
标题: ios - 某些插页式广告在点击 'X' 时不会关闭或关闭

我有一个应用程序在 UIPageViewController 上显示几页后显示插页式广告。通常广告没问题,我可以通过它自己的“X”按钮将其关闭。但是有一些广告(尤其是关于诸如《列王之战》之类的游戏的广告,我注意到了)无论我点击多少次“X”按钮都不会消失。

我什至有一段时间会在 5 秒后关闭诸如插页式广告之类的模式,但对于这些特定的广告,它就不起作用了。

这是我的代码:

func createAndLoadInterstitial() -> GADInterstitial {
    let interst = GADInterstitial(adUnitID: "..")
    interst.delegate = self
    let request = GADRequest()
    interst.load(request)

    return interst
}

func showInterstitial() {
    if interstitial.isReady {

            self.interstitial.present(fromRootViewController: self)
            self.timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.dismissInterstitial), userInfo: nil, repeats: false)

    } else {
        print("Ad wasn't ready")
    }
}

func dismissInterstitial() {

    self.dismiss(animated: true, completion: nil) //THIS WORKS FINE EXCEPT FOR THESE PARTICULAR ADS.

}

我尝试使用 DispatchQueue.main.async 确保它也在主线程上,但同样,这并非每次都有效。

有没有办法解决这个问题,或者我可能遗漏了什么?

谢谢。



Best Answer-推荐答案


以前没有使用过广告,但在游戏中看到了这种行为。我想到的事情:

  1. 它是否有一个委托(delegate)方法被调用然后你关闭广告?
  2. 如果没有委托(delegate)方法,则可能是广告“作弊”并无目的显示“x”按钮。

可能的解决方案:创建一个透明 View 并创建一个手势识别器并在点击时关闭如何?

关于ios - 某些插页式广告在点击 'X' 时不会关闭或关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42305057/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4