Admob banner change frame for different screen dimensions
NickName:behind the aura Ask DateTime:2015-06-11T08:01:40

Admob banner change frame for different screen dimensions

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 ];

Copyright Notice:Content Author:「behind the aura」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769378/admob-banner-change-frame-for-different-screen-dimensions

Answers
Daniel Storm 2015-06-11T01:35:58

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.\n\nadmobBannerView.adSize = kGADAdSizeBanner;\nadmobBannerView.frame = CGRectMake(0, self.view.frame.size.height - admobBannerView.frame.size.height , self.view.frame.size.width, admobBannerView.frame.size.height);\n\n\n\nx - Set to origin of 0 \ny - 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\nwidth - Set it to the width of the view: self.view.frame.size.width\nheight - Set it to the height of our GADBannerView: admobBannerView.frame.size.height\n\n\nBanner Ad Customization",


More about “Admob banner change frame for different screen dimensions” related questions

Admob banner change frame for different screen dimensions

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. I...

Show Detail

Admob banner not filling up full screen

My app was just released the other day. When I downloaded it to an iPhone 6 I noticed the admob banner didn't fill the full screen (look at the attached picture). The banner works fine on an iPad and

Show Detail

Admob banner ads and screen sizes

My problem, i have an app which i want to show admob banner ads, but only in layout/screen sizes for tablets 7" and 10". And just because there is more room for banner ads, because bigger screen si...

Show Detail

Is it a problem if my Admob Banner is not showing in small devices ? (it is like hidden under the screen)

So my app is working fine, but I have noticed that in small devices of 3.4" (480x800) in one activity as the admob banner is at the buttom of the screen and and the UI of my app doesn't fit

Show Detail

Set admob banner at the bottom of the screen/view?

I'm trying to set an AdMob Banner for my app. In my Activity I've got a ListView, so I need to put the Banner on the bottom of it. The admob banner appears in the middle of the screen. How to fix i...

Show Detail

Admob banner not sticking to bottom of uitableview swift

I've added admob banners into my app which are working fine except when my rows in the tableview don't completely fill up the screen. The banners then just sit under the last row, I'd like to force...

Show Detail

Add Admob banner to Screen

Can`t add admob banner as usual: // Create an ad. adView = new AdView(this, AdSize.BANNER, "*********************"); RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel2);

Show Detail

Admob Banner at the top of the screen

I want to have the Admob banner at the top of the screen instead of the bottom. This is what i copied from the Admob Documentations. func addBannerViewToView(_ bannerView: GADBannerView) {

Show Detail

AdMob ad banner not changing position (Swift 3)

Hi there I'm trying to change the position of my AdMob banner in one of my scenes. The ad displays successfully (and is hidden successfully) whenever I set it to be, but it doesn't take the positio...

Show Detail

Set Admob banner to appear at bottom of screen

I am currently using this code to display an Admob request; If I use this code, the banner appears, but at the top of the screen not the bottom; CGRect screenRect = [[UIScreen mainScreen] bounds]...

Show Detail