Admob 6.8.0:手动删除,隐藏或禁用横幅 [英] Admob 6.8.0: manually remove, hide or disable banners

查看:125
本文介绍了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.

尽管横幅显示得很完美,但它使bannerView_无法响应任何其他命令,因此,即使调用了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:手动删除,隐藏或禁用横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆