interstitialAd – iOS 8 beta 5在模拟器中不提供Xclosuresbutton

我对苹果的插页式广告存在问题。 我正在迅速做我的第一个应用程序,我想尽快放在App Store上。 但是,当我将obejctive-c的插页式广告代码改写为swift时,我可以展示广告,但是我没有Xclosuresbuuton,所以我无法closures它。 我还没有find任何其他的,我应该把这个button放在我自己的,它应该在那里默认。 我正在使用这个function:(我也不得不说,我使用的是精灵套件,所以我的视图控制器会自动将游戏redirect到Gamescene)

func showFullScreenAd() { if requestingAd == false { interstitial = ADInterstitialAd() interstitial!.delegate = self requestingAd = true } } func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) { self.interstitial = nil requestingAd = false } func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) { if interstitialAd != nil && self.interstitial != nil && self.requestingAd == true { interstitial!.presentInView(self.view) } } func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) { interstitial = nil requestingAd = false } func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) { interstitial = nil requestingAd = false } 

感谢您的帮助(这里是一张图片: http : //imgur.com/jKTWRiG )

—–更新—–这是解决scheme,只是工作。 我使UIView,其中我提出了广告和closuresbutton(在背景上的一些交叉图像)。 这可能不是最好的解决scheme,但应用程序商店接受,soooo:D

所有这些funcs被放置在GameViewController.swift(你不能简单地控制视图控制器从spritekit场景,你可以通过gameviewcontroller的单身,取决于你)

 func showFullScreenAd() { if requestingAd == false { interstitial = ADInterstitialAd() interstitial!.delegate = self requestingAd = true } } func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) { self.interstitial = nil requestingAd = false } func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) { if interstitialAd != nil && _interstitial != nil && requestingAd == true { self._adView = UIView() self._adView!.frame = self.view.bounds self.view.addSubview(_adView!) self.button = UIButton(frame: CGRect(x: 10, y: 10, width: 40, height: 40)) self.button!.setBackgroundImage(UIImage(named: "close_button"), forState: UIControlState.Normal) self.button!.addTarget(self, action: Selector("close"), forControlEvents: UIControlEvents.TouchDown) self.view.addSubview(button!) _interstitial!.presentInView(self._adView) requestingAd = false } UIViewController.prepareInterstitialAds() } func close() { self._adView!.removeFromSuperview() self.button!.removeFromSuperview() self._interstitial = nil } func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) { interstitial = nil requestingAd = false self._adView!.removeFromSuperview() self.button!.removeFromSuperview() } func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) { interstitial = nil requestingAd = false self._adView!.removeFromSuperview() self.button!.removeFromSuperview() } 

iOS 9.2.1,Xcode 7.2.1,ARC启用

我正在使用旧的方法:

 [interstitial presentFromViewController:self]; 

否则,状态栏仍然显示在容器视图中,并且没有“X”button,或者您没有使用Applebuild议的方法callback,即:

 [self requestInterstitialAdPresentation]; [interstitial presentInView:self.view]; 

如果它困扰你,你可以压制警告:

 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" //method goes here #pragma clang diagnostic pop 

请阅读这篇文章: iOS 7 iAd插页式广告不能被用户closures

我所做的是用这样的方法附上演示文稿,添加一些波兰语的一些条件:

*。H

 #import <UIKit/UIKit.h> #import <iAd/iAd.h> #import <AssetsLibrary/AssetsLibrary.h> @interface MainViewController : UIViewController <ADInterstitialAdDelegate> { ADInterstitialAd *interstitial; } @end 

* .M

 - (void)viewDidLoad { [super viewDidLoad]; [UIViewController prepareInterstitialAds]; self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual; interstitial = [[ADInterstitialAd alloc] init]; interstitial.delegate = self; } #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - (void)presentInterlude { if (interstitial.loaded && [self shouldPresentInterstitialAd]) { [interstitial presentFromViewController:self]; } else { nil; } } #pragma clang diagnostic pop - (void)cycleInterstitial { interstitial.delegate = nil; interstitial = [[ADInterstitialAd alloc] init]; interstitial.delegate = self; } - (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd { NSLog(@"loaded"); nil; } - (void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd { NSLog(@"unloaded"); [self cycleInterstitial]; } - (void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error { NSLog(@"failed, error: %@", error); [self cycleInterstitial]; } - (void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd { NSLog(@"finish"); } - (BOOL)interstitialAdActionShouldBegin:(ADInterstitialAd *)interstitialAd willLeaveApplication:(BOOL)willLeave { NSLog(@"action"); return true; } @end 

然后,当您准备好展示插页式广告时,请使用[self presentInterlude]

要使用“X”button(无需用户单击广告内容)来告知何时显示广告以及何时closures广告,则必须利用以下事实:当显示广告时, viewDidDissapear: ,并在广告已closuresviewDidAppear:被调用。 如果在调用viewDidAppear:之前需要准备好一些内容,请使用viewWillAppear:方法。

不要忘记在每次展示后循环播放插页式广告,插播式广告对象会在播放后发布,这是插页式广告和横幅广告之间最大的区别。

如果有人有更好的解决scheme,那么请分享和发布!

谢谢! 干杯。