Admob非页内广告和iOS

时间:2018-04-22 15:35:59

标签: ios swift admob statusbar

我有一个恼人的问题:

我必须每xxx秒显示一个插页式广告。该应用程序没有导航控制器。

有时,当插页式广告显示时,状态栏会消失,我没有胶水,为什么以及如何修复ist。

class InterstitialController: NSObject, GADInterstitialDelegate  {

static var shared = InterstitialController()

var view: UIViewController?

var interstitial: GADInterstitial!

func loadInterstitial() -> GADInterstitial {

    interstitial = GADInterstitial(adUnitID: "ca-app-pub-xxxxxxx")
    interstitial.delegate = self
    interstitial.load(GADRequest())
    return interstitial

}

func interstitialDidDismissScreen(_ ad: GADInterstitial) {
    interstitial = loadInterstitial()
    view?.view.layoutIfNeeded()
}

override init() {
    super.init()
    interstitial = loadInterstitial()

    Timer.scheduledTimer(withTimeInterval: 800000, repeats: true, block: { _ in
        if self.interstitial.isReady {
            guard let v = self.view else { return }
            self.interstitial.present(fromRootViewController: v)
        } else {
            print("Ad wasn't ready")
        }
    })
}

在每个控制器的viewWillAppear中,上面的view属性设置为" self"。

祝你好运, 帕斯卡

0 个答案:

没有答案