Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdMob Banner Size for retina display iphone

Tags:

admob

I have set my banner size as 320*50. For the Retina display, I have set it as 640*100. It's not displaying the banner at all. Can you please let me know what mistake I have made? It works when the size is 320*50, but not when it is 640*100.

like image 387
Arun Avatar asked Feb 17 '23 03:02

Arun


2 Answers

Yes, you do use the same size on the Retina devices.

However you shouldn't be setting the specific size at all. If you decide to convert your app to iPad as well then your ad code will all of a sudden stop working as it will only stretch half way across the screen.

Use the Smart banner size, and Admob will work it all out for you. For instance, here is some code from one of my apps that places a banner at the bottom of the screen. Note in particular the use of kGADAdSizeSmartBannerPortrait, this allows the resize of the ad banner.

//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];
like image 187
Peter Smith Avatar answered Feb 18 '23 17:02

Peter Smith


Use 320x50 on retina devices as well. It's the ad network's responsibility to come back with a 2x density image to fit onto your device, not your responsibility to make the frame twice as big.

like image 32
Eric Leichtenschlag Avatar answered Feb 18 '23 15:02

Eric Leichtenschlag