1
如何通过单击按钮不是每次显示AdMob广告?是否有可能在广告点击次数或广告显示的时间之后设置?不是每次都显示AdMob广告
import UIKit
import GoogleMobileAds
class ViewController: UIViewController, GADBannerViewDelegate {
@IBOutlet var BannerView: GADBannerView!
var interstitial: GADInterstitial!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
interstitial = GADInterstitial(adUnitID: "ca-app-pub-1469592343938512/3581855984")
let request2 = GADRequest()
interstitial.loadRequest(request2)
let request = GADRequest()
request.testDevices = [kGADSimulatorID]
BannerView.delegate = self
BannerView.adUnitID = "ca-app-pub-1469592343938512/2613153588"
BannerView.rootViewController = self
BannerView.loadRequest(request)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func createAD() -> GADInterstitial{
let interstitial = GADInterstitial(adUnitID: "ca-app-pub-1469592343938512/3581855984")
interstitial.loadRequest(GADRequest())
return interstitial
}
@IBAction func ShowAD(sender: AnyObject) {
if (interstitial.isReady){
interstitial.presentFromRootViewController(self)
interstitial = createAD()
}
}
}
你能给我一个适合我的代码的例子吗? –
我会发表一个编辑原始答案的例子 – iGenio
能否请你给我一个例子与上面的代码我总是会得到错误... –