2
有沒有人知道如何以編程方式顯示50pt高度的GADBannerView?GADBannerView沒有設置高度
在我viewDidLoad中,
int heightOfBanner = 50;
GADBannerView *banner =
[[GADBannerView alloc]
initWithAdSize:GADAdSizeFullWidthPortraitWithHeight(heightOfBanner)
origin:CGPointMake(0, CGSizeFromGADAdSize(kGADAdSizeBanner).height)];
banner.adUnitID = @"ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxx";
banner.rootViewController = self;
[self.view addSubview:banner];
[banner loadRequest:[GADRequest request]];
以上代碼簡化版,顯示任何東西。
但是當heightOfBanner設置爲較高值(例如200)時,它運行良好(但橫幅的高度不是50)。
我podfile低於:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'Google-Mobile-Ads-SDK', '~> 7.0'
,我也 「吊艙安裝」 成功。
它不起作用。但它似乎是正確的。 –
@TsuyoshiEndo我已經更新了我的答案,因此'GADBannerView'的寬度橫跨整個屏幕的寬度。 –
它運作良好! 我瞭解_當我想要定位特定的點時,請不要使用精確的dimensions_和_use center_。 所以,當我在UINavigationController中使用一個UIViewControllers時,這個代碼是否工作正常? –