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时,这个代码是否工作正常? –