2016-07-29 96 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拖動到父級,然後選擇「等寬」。