gpt4 book ai didi

ios - 当内容不可用时,iAd 显示一条白线?

转载 作者:行者123 更新时间:2023-11-29 12:52:21 25 4
gpt4 key购买 nike

当没有内容可显示时,我的广告横幅被替换为白色横幅。根据提供的代码,这有什么原因吗?另外,当 iAd 不可用时,是否可以用 AdMob 适本地补充横幅广告?

//iAd Advertising
#pragma mark iAd Delegate Methods

- (void) bannerViewDidLoadAd:(ADBannerView *)banner {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];

}

- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
advertisement.hidden = YES;


}

我已经尝试过使用 Google AdMob 对其进行补充:

#pragma mark iAd Delegate Methods

- (void) bannerViewDidLoadAd:(ADBannerView *)banner {

advertisement.hidden = NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
bannerView_.hidden = YES;

} // if there is an internet connection, load the iAd with a 1 second fade in effect

- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

//MAKE SURE THIS IS RIGHT OR FIGURE OUT HOW TO MAKE IT RIGHT

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
advertisement.hidden = YES;

//2
bannerView_.hidden = NO;
bannerView_ = [[GADBannerView alloc]initWithFrame:CGRectMake(0, 20, 320, 50)];
bannerView_.adUnitID = @"//ca-app-pub-";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];

}

我制作横幅 View 的导出并将它们隐藏或显示是错误的吗?它不起作用,它总是只显示其中一个广告,并且如前所述,当 iAd 不存在时,它只显示一个白色横幅,里面什么也没有,这对应用程序的目的来说是侵入性的而不是装饰性的。

基于此,我做错了什么?对于这两种情况,即为什么 iAd 显示白色横幅,以及为什么 AdMob 不补充自身。

最佳答案

在 StoryBoard 中,将横幅设置为隐藏。在您的 viewController(定义为横幅的委托(delegate))中,放置此代码:

 - (void)bannerViewDidLoadAd:(ADBannerView *)banner {
[banner setHidden:false];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"Error : %@",error.description);
[banner setHidden:true];
}

关于ios - 当内容不可用时,iAd 显示一条白线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22120730/

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