菜鸟教程小白 发表于 2022-12-11 19:01:49

ios - 某些插页式广告在点击 'X' 时不会关闭或关闭


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

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

<p>这是我的代码:</p>

<pre><code>func createAndLoadInterstitial() -&gt; GADInterstitial {
    let interst = GADInterstitial(adUnitID: &#34;..&#34;)
    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(&#34;Ad wasn&#39;t ready&#34;)
    }
}

func dismissInterstitial() {

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

}
</code></pre>

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

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

<p>谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>以前没有使用过广告,但在游戏中看到了这种行为。我想到的事情:</p>

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

<p><strong>可能的解决方案</strong>:创建一个透明 View 并创建一个手势识别器并在点击时关闭如何? </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 某些插页式广告在点击&#39;X&#39; 时不会关闭或关闭,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42305057/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42305057/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 某些插页式广告在点击 &#39;X&#39; 时不会关闭或关闭