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
能否請你給我一個例子與上面的代碼我總是會得到錯誤... –