我集成了admob.My應用程序支持縱向和橫向模式。在縱向模式下,它可以完美運行,但橫向模式不會改變廣告尺寸。橫向模式下,bannerview廣告包含左右空間。更改GADBannerView中的廣告尺寸
如何更改廣告?
請幫助我。
我集成了admob.My應用程序支持縱向和橫向模式。在縱向模式下,它可以完美運行,但橫向模式不會改變廣告尺寸。橫向模式下,bannerview廣告包含左右空間。更改GADBannerView中的廣告尺寸
如何更改廣告?
請幫助我。
只需在autroate deleagate方法中將GADBannerView框架的寬度設置爲self.view.frame.size.width即可。像這樣
- (BOOL)shouldAutorotate
{
CGRect tframe = _adView.frame;
tframe.size.width = self.view.frame.size.width;
_adView.frame = tframe;
}
不再有效。立即致電廣告服務器,然後是didFailToReceiveAdWithError: – Vaiden
如果你正在尋找的全寬度的廣告,使用智能橫幅廣告格式:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInt
duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(toInt)) {
self.adBanner.adSize = kGADAdSizeSmartBannerLandscape;
} else {
self.adBanner.adSize = kGADAdSizeSmartBannerPortrait;
}
}
更改廣告尺寸這樣使用新的系統會自動向你的新請求尺寸。
我的解決辦法是簡單地按比例橫幅畫面,周圍的一切似乎失敗:
斯威夫特答案恭維OBJ-C之一。
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.currentDevice().orientation.isLandscape.boolValue {
self.bannerView.adSize = kGADAdSizeSmartBannerLandscape;
} else {
self.bannerView.adSize = kGADAdSizeSmartBannerPortrait;
}
}
對於風景 iPad和iPhone
[bannerView setAdSize:GADAdSizeFullWidthLandscapeWithHeight(90)];
[bannerView setAdSize:GADAdSizeFullWidthLandscapeWithHeight(50)];
對於肖像 iPad和iPhone
[bannerView setAdSize:GADAdSizeFullWidthPortraitWithHeight(90)];
[bannerView setAdSize:GADAdSizeFullWidthPortraitWithHeight(50)];
[在iPhone自定義尺寸顯示AdMob廣告]的
可能重複(HTTP:/ /stackoverflow.com/questions/12793865/display-admob-ads-with-a-custom-size-in-iphone) – josliber