本文介绍了Admob的旗帜变化框架不同的屏幕尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的Admob的广告在所有不同的iPhone的屏幕尺寸,苹果公司提供的调整,但我不知道如何得到它的自动或通过使用不同的code调整。

在我的 viewDidLoad中

  bannerView_ = [[GADBannerView页头] initWithFrame:方法CGRectMake(0,430,320,50);
bannerView_.adUnitID = @;
bannerView_.rootViewController =自我;
[self.view addSubview:bannerView_]。
[bannerView_ loadRequest:[GADRequest要求];
GADRequest *请求= [GADRequest请求]
request.testDevices = [NSArray的arrayWithObjects:@,零]
 

解决方案

您需要设置 adSize 属性为谷歌的一套旗帜尺寸 kGADAdSizeBanner 。然后,设置你的 GADBannerView 相对视图。下面code则以 GADBannerView 视图底部

  admobBannerView.adSize = kGADAdSizeBanner;
admobBannerView.frame = CGRectMake(0,self.view.frame.size.height  -  admobBannerView.frame.size.height,self.view.frame.size.width,admobBannerView.frame.size.height);
 

  • X - 设置为原产地 0
  • - 设置原点到视图的高度。但是,这将使其显示关闭屏幕的底部。因此,我们必须减去我们的 GADBannerView 将它搬上银幕的高度: self.view.frame.size.height - admobBannerView.frame .size.height
  • 宽度 - 将其设置为视图的宽度: self.view。 frame.size.width
  • 高度 - 将其设定为我们的 GADBannerView 的高度: admobBannerView.frame。 size.height

横幅广告定制

I'm trying to get my Admob ad to adjust between all the different iPhone screen sizes that Apple offers, but I can't figure out how to get it to adjust automatically or by using different code.

In my viewdidload

bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0, 430, 320, 50)];
bannerView_.adUnitID = @"";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:@"", nil ];
解决方案

You need to set the adSize property to Google's set banner size kGADAdSizeBanner. Then you set your GADBannerView's frame relative to the view. The following code places the GADBannerView on the bottom of your view.

admobBannerView.adSize = kGADAdSizeBanner;
admobBannerView.frame = CGRectMake(0, self.view.frame.size.height - admobBannerView.frame.size.height , self.view.frame.size.width, admobBannerView.frame.size.height);

  • x - Set to origin of 0
  • y - Set origin to the view's height. But this will make it appear off the bottom of the screen. So, we must subtract the height of our GADBannerView to move it up onto the screen: self.view.frame.size.height - admobBannerView.frame.size.height
  • width - Set it to the width of the view: self.view.frame.size.width
  • height - Set it to the height of our GADBannerView: admobBannerView.frame.size.height

Banner Ad Customization

这篇关于Admob的旗帜变化框架不同的屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:20