首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Segue之前添加Admob Interstitial?

如何在Segue之前添加Admob Interstitial?
EN

Stack Overflow用户
提问于 2016-07-27 03:43:34
回答 1查看 466关注 0票数 2

我已经试着解决这个问题很长一段时间了,但是我想不出怎么解决它。

目前,我已经将Admob添加到我的项目中,并且间隙正在显示,但当我退出间隙时,它会返回到我之前的VC (在那里创建间隙实例)。

正如您在下面看到的,我正在尝试将它们添加到我的Tabbar函数中。但分段永远不会发生,在间隙之前也不会显示警报。我想展示广告,然后转到VC。我希望用户看到警报并在看到间隙之前按下"OK“。

任何帮助都是很棒的!

代码语言:javascript
复制
//TabBar Functions

    func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
        if (item.tag == 1) {

            if (self.interstitial.isReady) {
                self.interstitial.presentFromRootViewController(self)
            }

            self.performSegueWithIdentifier("showStore", sender: nil)

        } else if (item.tag == 2) {

            let alert = UIAlertController(title: "Coming Soon!", message: "Loadout", preferredStyle: .Alert)

            alert.addAction(UIAlertAction(title: "Got It!", style: .Default, handler: nil))

            if (self.interstitial.isReady) {
                self.interstitial.presentFromRootViewController(self)
            }

            self.presentViewController(alert, animated: true, completion: nil)

            return

        } else if (item.tag == 3) {

            let alert = UIAlertController(title: "Coming Soon!", message: "God's Tower", preferredStyle: .Alert)

            alert.addAction(UIAlertAction(title: "Got It!", style: .Default, handler: nil))

            if (self.interstitial.isReady) {
                self.interstitial.presentFromRootViewController(self)
            }

            self.presentViewController(alert, animated: true, completion: nil)

            return

        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-28 00:31:10

设置你的GADInterstitial的代表,一旦广告被取消,就开始分段。

代码语言:javascript
复制
// Add this where you're creating your GADInterstitial
interstitial.delegate = self

func interstitialDidDismissScreen(ad: GADInterstitial!) {
  // Segue to your view controller here
}

有关广告事件的完整列表,请参阅GADInterstitialDelegate implementation

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38598615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档