我使用UITabBarController-iAds的修改版本使iAds幾乎完美地工作。我唯一的問題是第一個廣告加載我的觀點被覆蓋。一旦廣告在30秒後刷新,視圖的大小就可以調整。iAd涵蓋了我對第一次加載的看法
我用下面的代碼:
- (void)layoutBanner
{
float height = 0.0;
ADBannerView *_banner = (ADBannerView *)[self.view viewWithTag:12];
CGRect bounds = [UIScreen mainScreen].bounds;
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
_banner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
} else {
_banner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
}
//When compiling against iOS 8 SDK this needs to be height, regardless of the actual device orientation
height = bounds.size.height;
CGSize bannerSize = [ADBannerView sizeFromBannerContentSizeIdentifier:_banner.currentContentSizeIdentifier];
//Get content view
UIView *_contentView = self.selectedViewController.view;
CGRect contentFrame = _contentView.frame;
CGRect bannerFrame = _banner.frame;
if (_banner.isBannerLoaded) {
if (iOS7) {
contentFrame.size.height = height - bannerSize.height;
bannerFrame.origin.y = contentFrame.size.height - self.tabBar.frame.size.height;
} else {
contentFrame.size.height = height - self.tabBar.frame.size.height - bannerSize.height;
bannerFrame.origin.y = contentFrame.size.height;
}
} else {
if (iOS7) {
contentFrame.size.height = height;
bannerFrame.origin.y = bounds.size.height;
} else {
contentFrame.size.height = height - self.tabBar.frame.size.height;
bannerFrame.origin.y = bounds.size.height;
}
}
[UIView animateWithDuration:0.25 animations:^{
_banner.frame = bannerFrame;
_contentView.frame = contentFrame;
} completion:^(BOOL finished) {
[self.view bringSubviewToFront:_banner];
}];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"Did load");
[self layoutBanner];
}
任何想法?
嗯是的我想我遵循你的邏輯。廣告加載後,佈局會更新,以指定您對齊的廣告的位置,然後對其進行動畫製作。蘋果公司的實施情況稍有不同,所以我可以試一試。 – Leon 2014-11-07 10:15:46
嘗試添加「[self.view bringSubviewToFront:_banner];」到實現橫幅的控制器的viewDidLoad方法。讓我知道結果。 – 2014-11-08 20:22:20
我不能這樣做,因爲我發佈的代碼是在一個類別而不是ViewController。 – Leon 2014-11-09 23:03:13