Swift AdMob ad错误尺寸

Swift AdMob ad错误尺寸,swift,admob,Swift,Admob,我在五月的应用程序中使用AdMobs smart banner,我按照谷歌《入门》中的建议做了一切,除了横幅大小不是固定的320x50,它的屏幕宽度x50。在自动布局中,我为水平中心添加了1个约束,为屏幕宽度添加了1个约束。如果我在模拟器上运行它,我会工作得很好,但在设备上我会遇到以下错误: <Google> Unable to set adSize property. Not enough space to show ad with custom size, {600, 50}.

我在五月的应用程序中使用AdMobs smart banner,我按照谷歌《入门》中的建议做了一切,除了横幅大小不是固定的
320x50
,它的
屏幕宽度x50
。在自动布局中,我为水平中心添加了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

这是我的代码:

@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())
这些是我的限制


您需要添加宽度约束


按住Ctrl键从AdView拖动到父视图,然后选择“相等宽度”。

宽度没有约束。Lol没问题。总是一些小事。
@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())