简体   繁体   English

AdMob横幅广告的底部工具栏

[英]AdMob Banner Covers Bottom Toolbar

I have just loaded an AdMob test banner to my ViewController. 我刚刚将AdMob测试横幅加载到我的ViewController。 I dragged in a View at storyboard level and set it to be the AdMob banner (and I fixed it's size to : 320x50). 我在情节提要板中拖动了一个View,并将其设置为AdMob标语(并将其尺寸固定为:320x50)。

But it covers my bottom toolbar. 但这涵盖了我的底部工具栏。

In Xcode, I have set my toolbar (using storyboard constraints) to the bottom of the view (0 distance to bottom of view); 在Xcode中,我已将工具栏(使用情节提要约束)设置为视图的底部(到视图底部的距离为0)。 and I set the AdMob banner view to sit just above the bottom toolbar (0 distance to bottom toolbar, using constraints in the storyboard). 然后将AdMob横幅视图设置为位于底部工具栏的正上方(使用情节提要中的约束,距离底部工具栏的距离为0)。

When I run the simulator on my device, the banner appears at the bottom of the view on top of and covering my bottom toolbar. 当我在设备上运行模拟器时,横幅会显示在视图底部的顶部,并覆盖底部的工具栏。

How can I set my parameters so that the banner (if it displays) will always show just on top of the bottom toolbar, not cover it? 如何设置参数,以便横幅广告(如果显示的话)始终显示在底部工具栏的顶部,而不是覆盖它?

I found a the exact same question here : 我在这里找到了完全相同的问题:

AdView Banner (SubView) covers the bottom toolbar in my app. AdView标语(SubView)覆盖了我应用中的底部工具栏。 How do I make sure the toolbar is fixed below the banner? 如何确保工具栏固定在横幅下方?

but the answer (which was not accepted) was : 但是答案(不被接受)是:

I had this same problem, simple fix for me. 我遇到了同样的问题,对我来说很简单。 You probably have "self.canDisplayBannerAds = YES;" 您可能具有“ self.canDisplayBannerAds = YES;”。 in your -viewDidLoad method. 在您的-viewDidLoad方法中。 Move it to your -viewDidAppear method instead and see if that fixes it. 而是将其移动到您的-viewDidAppear方法,并查看是否可以解决该问题。

I don't have a viewDidAppear method currently in my ViewController.swift file. 我的ViewController.swift文件中当前没有viewDidAppear方法。

I also realise that the actual AdMob banner displayed on my iPhone 6 is full width - while I set a fixed size to the view in my storyboard that 'holds' the AdMob banner. 我还意识到,iPhone 6上显示的实际AdMob横幅是全角的-而我在故事板上的视图上设置了固定尺寸,以“容纳” AdMob横幅。 So obviously, the constraints I set for the banner at storyboard level is being overridden here. 所以很明显,我在情节提要板上为横幅设置的约束在这里被覆盖。

What should I do? 我该怎么办?

Thanks. 谢谢。

I followed the advice from the related question: 我遵循了相关问题的建议:

AdView Banner (SubView) covers the bottom toolbar in my app. AdView标语(SubView)覆盖了我应用中的底部工具栏。 How do I make sure the toolbar is fixed below the banner? 如何确保工具栏固定在横幅下方?

I had this same problem, simple fix for me. 我遇到了同样的问题,对我来说很简单。 You probably have "self.canDisplayBannerAds = YES;" 您可能具有“ self.canDisplayBannerAds = YES;”。 in your -viewDidLoad method. 在您的-viewDidLoad方法中。 Move it to your -viewDidAppear method instead and see if that fixes it. 而是将其移动到您的-viewDidAppear方法,并查看是否可以解决该问题。

It worked for me also - in my own context. 在我自己的上下文中,它也对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM