我在may app中使用了AdMobs智能横幅广告,我在Googles入门中做了一切建议,除了横幅尺寸不是320x50
,screen widthx50
。在自动布局中,我为水平中心添加了1个约束,为屏幕宽度添加了1个约束。如果我在模拟器上运行它我工作得很好但在设备上我收到此错误:
<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())
这些是我的约束
答案 0 :(得分:1)
您需要添加宽度约束。
Ctrl-从AdView拖动到父级并选择“等宽”。