我的 iAd 集成无法正常工作。我尝试实施全屏广告。广告出现了,但是当我按下“X”按钮关闭时,它并没有关闭。
也许您可以在我的代码中找到问题?我不知道要改变什么,并且投入了大量时间来解决这个问题,但没有成功。
更新
它适用于[interstitial presentFromViewController:self];
但不适[interstitial presentInView:self.view];
用于 iOS 7 不推荐使用 presentFromViewController 问题...那么我该如何更改它?
- (void)viewDidLoad
{
requestingAd = NO;
[self showFullScreenAd];
}
//Interstitial iAd
-(void)showFullScreenAd {
//Check if already requesting ad
if (requestingAd == NO) {
interstitial = [[ADInterstitialAd alloc] init];
interstitial.delegate = self;
self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual;
[self requestInterstitialAdPresentation];
NSLog(@"interstitialAdREQUEST");
requestingAd = YES;
}//end if
}
-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
interstitial = nil;
requestingAd = NO;
NSLog(@"interstitialAd didFailWithERROR");
NSLog(@"%@", error);
}
-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdDidLOAD");
if (interstitialAd != nil && interstitial != nil && requestingAd == YES) {
[interstitial presentInView:self.view];
NSLog(@"interstitialAdDidPRESENT");
}//end if
}
-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
interstitial = nil;
requestingAd = NO;
NSLog(@"interstitialAdDidUNLOAD");
}
-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
interstitial = nil;
requestingAd = NO;
NSLog(@"interstitialAdDidFINISH");
}
先感谢您 :)