gpt4 book ai didi

ios - Interstitial iAd 实现

转载 作者:行者123 更新时间:2023-11-28 17:52:33 25 4
gpt4 key购买 nike

我遇到了 iAd 全屏广告的问题。我像这样实现 iAd:

 -(void)showFullScreenAd {
//Check if already requesting ad
if (requestingAd == NO) {
[ADInterstitialAd release];
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;
[interstitialAd release];
[ADInterstitialAd release];
requestingAd = NO;
NSLog(@"interstitialAd didFailWithERROR");
NSLog(@"%@", error);
}

-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdDidLOAD");
if (interstitialAd != nil && interstitial != nil && requestingAd == YES) {
[interstitial presentFromViewController:self];
NSLog(@"interstitialAdDidPRESENT");
}//end if
}

-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
interstitial = nil;
[interstitialAd release];
[ADInterstitialAd release];
requestingAd = NO;
NSLog(@"interstitialAdDidUNLOAD");
}

-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
interstitial = nil;
[interstitialAd release];
[ADInterstitialAd release];
requestingAd = NO;
NSLog(@"interstitialAdDidFINISH");
}

我正在调用“showFullScreenAd”来展示广告。但是在调用它 10 次之后我收到了这条消息,即使我关闭了这个 View Controller 并设置了 interstitial = nill,:

警告:目前存在 10 个以上的 ADBannerView 或 ADInterstitialView 实例。这是对 iAd API 的误用,广告效果会因此受到影响。此消息仅打印一次。

我猜问题在于关闭插页式广告。因为声明 interstitial = [[ADInterstitialAd alloc] init];

每次都制作新的插页式广告实例。

我看到的主题很少,但没有回答如何正确关闭这些实例。

最佳答案

需要调用viewDidLoad中的方法。

-(void)viewDidLoad 
{
[self showFullScreenAd];
}

我在调用viewWillLayoutSubviews中的方法时遇到了这个问题。

关于ios - Interstitial iAd 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28096317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com