Admob 6.8.0: manually remove, hide or disable banners(Admob 6.8.0:手动移除、隐藏或禁用横幅)
问题描述
这里有很多类似的问题,但没有一个解决方案适用于最新的 AdMob SDK.至少我不能让它工作.
There are tons of similar questions here, but none of the solutions are working on the latest AdMob SDK. At least I couldn't make it work.
加载中:
- (void)AdMob_Banner_On
{
bannerView_.adUnitID = kAdMobID;
bannerView_.rootViewController = self;
[bannerView_ loadRequest:[GADRequest request]];
(...)
}
它们运行良好,现在删除...我找到的所有解决方案都很简单,但它们不起作用:
They are running perfectly, and now removing... all solutions I found are quite simple, but they don't work:
- (void)AdMob_Banner_Off {
NSLog(@"Admob: Turning Off");
bannerView_.hidden = YES;
[bannerView_ removeFromSuperview];
[bannerView_ setDelegate:nil];
bannerView_ = nil;
}
有时我需要所有屏幕都可用,但我不能一直展示广告.有什么想法吗?
Some times I need all screen available, I can't show ads all the time. Any ideas?
推荐答案
如果有人遇到同样的问题,这是我的解决方法.
In case anyone has the same problem, here is how I fix it.
问题是我是AdMob_Banner_On"方法上的行被颠倒了.
The problem was that I was that the lines on the "AdMob_Banner_On" method were inverted.
虽然横幅完美显示,但它使横幅视图_无法响应任何其他命令,因此即使调用了 AdMob_Banner_Off,也没有发生任何事情.
Although the banner was showing up perfectly, it made the bannerView_ unable to respond to any other command, so even if the AdMob_Banner_Off was called, nothing was happening.
现在代码可以工作了.你应该做的第一件事是设置横幅的位置,然后调用它.那是我的问题.这段代码应该可以正常工作:
Now the code that works. The first thing you should do it to set the position of the banner, and then calling it. That was my problem. This code should work fine:
开启:
- (void)AdMob_Banner_On {
NSLog(@"Admob: Turning On");
// Making it on the bottom:
CGPoint origin = CGPointMake(0.0,self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait origin:origin];
bannerView_.adUnitID = kAdMobID;
bannerView_.rootViewController = self;
bannerView_.delegate = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
}
- (void)AdMob_Banner_Off: {
NSLog(@"Admob: Turning Off");
[bannerView_ removeFromSuperview];
}
使用此代码,您可以根据需要打开和关闭横幅.这对于不能一直显示横幅的应用很有用.
With this code you can turn on and off the banner as you want. This is useful to apps that can't show the banner all the time.
这篇关于Admob 6.8.0:手动移除、隐藏或禁用横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Admob 6.8.0:手动移除、隐藏或禁用横幅


- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01