如何在 Segue 之前添加 Admob Interstitial?
How to add Admob Interstitial before Segue?
我已经尝试解决这个问题好一段时间了,但不知道如何解决它。
目前我已经将 Admob 添加到我的项目中并且正在显示插页式广告,但是当我退出插页式广告时,它 returns 我回到了我之前的 VC(创建插页式广告实例的地方)。
正如您在下面看到的,我正在尝试将它们添加到我的 Tabbar 功能中。但是 segue 永远不会发生,也不会在插页式广告之前显示警报。我想展示广告,然后转到 VC。我希望用户在看到插页式广告之前看到警报并按 "OK"。
任何帮助都会很棒!
//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
}
}
设置您的 GADInterstitial
的委托,然后在广告关闭后继续。
// Add this where you're creating your GADInterstitial
interstitial.delegate = self
func interstitialDidDismissScreen(ad: GADInterstitial!) {
// Segue to your view controller here
}
有关广告事件的完整列表,请参阅 GADInterstitialDelegate implementation。
我已经尝试解决这个问题好一段时间了,但不知道如何解决它。
目前我已经将 Admob 添加到我的项目中并且正在显示插页式广告,但是当我退出插页式广告时,它 returns 我回到了我之前的 VC(创建插页式广告实例的地方)。
正如您在下面看到的,我正在尝试将它们添加到我的 Tabbar 功能中。但是 segue 永远不会发生,也不会在插页式广告之前显示警报。我想展示广告,然后转到 VC。我希望用户在看到插页式广告之前看到警报并按 "OK"。
任何帮助都会很棒!
//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
}
}
设置您的 GADInterstitial
的委托,然后在广告关闭后继续。
// Add this where you're creating your GADInterstitial
interstitial.delegate = self
func interstitialDidDismissScreen(ad: GADInterstitial!) {
// Segue to your view controller here
}
有关广告事件的完整列表,请参阅 GADInterstitialDelegate implementation。