iAd插页式广告不一致? 而根本不在模拟器上

iAd插页式广告在iPhone模拟器上根本没有显示出来,而且它们在我的iPhone上并不一致。 我已经进入开发人员设置,将填充率更改为100%,然后启用无限广告展示。 没有什么区别…一个插页式广告通常会首次显示它的设想,然后不会再显示几分钟到十五分钟的任何地方。 不知道是什么造成了时间的差异。

此外,似乎没有办法来跟踪插页式广告是否会显示或不显示/如果实际显示或不显示。 我意识到有一个插页式委托​​,但似乎不再使用。 我调用插页式广告的方式是使用viewController.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Automatic

谢谢!

因此,使用requestInterstitialAdPresentation似乎只能在您的ADInterstitialPresentationPolicy设置为“ Automatic 。 在使用Manual ADInterstitialPresentationPolicy实施您的插页式广告时,您必须使用ADInterstitialPresentationPolicy以您自己的间隔呈现广告。 以这种方式呈现插页式广告时,不会使用自己的closuresbutton加载自己。 所以,我所做的就是创build一个UIView来呈现插页式广告,并使用插页式广告委托方法来closuresUIView 。 testing时仍会出现与从iAdnetworking接收广告的不一致。 有时候您会收到一则广告,有时无法加载,这使得我们可能需要一个新的广告,有时甚至没有任何反应。 这似乎是iAd的插页式广告的本质。

 import UIKit import iAd // Import iAd class ViewController: UIViewController, ADInterstitialAdDelegate { // Include the delegate var iAdInterstitial = ADInterstitialAd() // Our ad var iAdInterstitialView = UIView() // View to present our ad in var adLoaded = false // Bool to keep track if an ad is loaded or not override func viewDidLoad() { super.viewDidLoad() setupAd() } func setupAd() { // Set presentation to manual so we can choose when to present the interstitial // Setting this will also fetch an interstitial ad for us self.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Manual iAdInterstitial.delegate = self // Set the delegate // Make our view the same size as the view we will be presenting in iAdInterstitialView.frame = self.view.bounds } func requestNewAd() { // This will fetch an ad for us ViewController.prepareInterstitialAds() println("Requesting new ad") } @IBAction func presentAdButton(sender: AnyObject) { if (adLoaded) { // We have an ad that is loaded so lets present it self.view.addSubview(iAdInterstitialView) iAdInterstitial.presentInView(iAdInterstitialView) } else { // No ad has been loaded println("Ad not loaded") } } func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) { // Kinda works as expected // Sometimes is called prematurely // Sometimes takes minutes after ad is dismissed to be called println("interstitialAdDidUnload") // Get new ad adLoaded = false iAdInterstitialView.removeFromSuperview() requestNewAd() } func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) { // Failed to load ad so lets try again println("didFailWithError: \(error)") requestNewAd() } func interstitialAdWillLoad(interstitialAd: ADInterstitialAd!) { // There is an ad and it has begun to download println("interstitialAdWillLoad") } func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) { // We got an ad println("interstitialAdDidLoad") adLoaded = true } func interstitialAdActionShouldBegin(interstitialAd: ADInterstitialAd!, willLeaveApplication willLeave: Bool) -> Bool { println("interstitialAdActionShouldBegin") return true; } func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) { // Done with this ad. Lets get a new one println("interstitialAdActionDidFinish") iAdInterstitialView.removeFromSuperview() adLoaded = false requestNewAd() }