AdMob banner size error When used with Autolayout

For a long time I struggled with the following problem: I have a quick project that has autostart, I work with any height and any width. I have adbanner whos height 50 and the side is attached to the super view.

when i run i get this error:

Unable to set adSize property. There is not enough space to display ads with a non-standard size, {600, 50}. Please use the size corresponding to the current screen borders {320, 568}.

I read a lot of messages here, either they do not use autolayout or for android: AdMob banner size for iphone retina

resize adob banner dynamically

adMob | Increase banner size?

How to create admob banner programmatically?

How to specify adUnitId programmatically for AdMob?

This google link, which was for android again, was somewhat useful for my thinking https://developers.google.com/mobile-ads-sdk/docs/dfp/android/banner?hl=en

After reading a lot of loosely related things. I am writing this line:

adBannerView.adSize = kGADAdSizeBanner

Which should solve the problem, since I am on the iPhone and Banner is 320x50 I also tried kGADAdSizeSmartBannerPortrait

But I still see the error, and the ad is not displayed. I thought it might be because of its test device. I did this too ...

if debug{ var devices: [String] = ["fe2b6df035b7b0729ae7d33cf35d2aa9"] GADRequest().testDevices = devices } else{ adBannerView.loadRequest(GADRequest()) } 

But no luck. Does anyone have some pointers for me.

+6
source share

All Articles