视网膜显示iphone的AdMob Banner尺寸

时间:2013-06-25 13:27:01

标签: admob

我将横幅尺寸设置为320 * 50。对于Retina显示器,我将其设置为640 * 100。它根本不显示横幅。你能告诉我我犯了什么错误吗?它适用于尺寸为320 * 50但不适用于640 * 100的情况。

2 个答案:

答案 0 :(得分:5)

是的,你在Retina设备上使用相同的尺寸。

但是,您根本不应该设置特定大小。如果您决定将应用转换为iPad,那么您的广告代码会突然停止工作,因为它只会在屏幕的一半延伸。

使用智能横幅尺寸,Admob将为您全力以赴。例如,以下是我的一个应用程序中的一些代码,它们在屏幕底部放置横幅。请特别注意使用kGADAdSizeSmartBannerPortrait,这样可以调整广告横幅的大小。

//Admob

// Available AdSize constants are explained in GADAdSize.h.
GADBannerView *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
bannerView_.rootViewController = self;
bannerView_.adUnitID = @"ca-app-pub-xxxxxxxxx/xxxx";

// Position the ad at the bottom of screen.
// By default it would be postitioned at (0,0)
bannerView_.frame = CGRectMake( 0,
                              self.view.frame.size.height - bannerView_.frame.size.height,
                              bannerView_.frame.size.width,
                              bannerView_.frame.size.height );

bannerView_.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin;

[self.view addSubview:bannerView_];

// Initiate a generic request to load it with an ad.
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
                       GAD_SIMULATOR_ID,
                       nil];
[bannerView_ loadRequest:request];

答案 1 :(得分:4)

在视网膜设备上也使用320x50。广告网络有责任回归2x密度图像以适应您的设备,而不是您有责任将框架设置为两倍大。

相关问题