2016-07-29 76 views
0

我在可能的应用中使用AdMobs智能横幅广告,除了横幅广告尺寸未修正320x50及其screen widthx50之外,我做了所有建议。在自动布局中,我添加了1个水平中心约束和1个屏幕宽度约束。如果我运行模拟器上我的伟大工程,但在设备上,我得到这个错误:Swift AdMob广告尺寸错误

<Google> Unable to set adSize property. Not enough space to show ad with custom size, {600, 50}. Please use a size that fits the current screen bounds of {320, 568}. 
<Google> To get test ads on this device, call: request.testDevices = @[ @"bb3f8f97887" ]; 
<Google> Unable to set adSize property. Not enough space to show ad with custom size, {600, 50}. Please use a size that fits the current screen bounds of {320, 568}. 
<Google> Invalid Request. Ad size will not fit on screen 

如果我登录我得到这个GADBannerView的视图大小(在iPhone 5上运行):

Size: (0.0, 0.0, 320.0, 50.0) 

这是我的代码:

@IBOutlet weak var bannerView: GADBannerView! 

bannerView.adUnitID = "ca-app-pub-394/216" 
bannerView.adSize = kGADAdSizeSmartBannerPortrait 
bannerView.rootViewController = self 
print("Size: ",bannerView.bounds) 
bannerView.loadRequest(GADRequest()) 

这是我的约束

+1

对宽度没有限制。 – TheValyreanGroup

+0

Lol没问题。它总是小事。 – TheValyreanGroup

回答

1

您需要添加一个宽度约束。

按住Ctrl从AdView拖动到父级,然后选择“等宽”。