gpt4 book ai didi

ios - iAd 涵盖了我对第一次加载的看法

转载 作者:行者123 更新时间:2023-11-29 10:36:35 28 4
gpt4 key购买 nike

我使用 UITabBarController-iAds 的修改版本让 iAds 几乎完美地工作.我遇到的唯一问题是在第一次加载广告时我的观点就被覆盖了。一旦广告在 30 秒后刷新, View 就会调整大小。

我正在使用以下代码:

- (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];
}

有什么想法吗?

最佳答案

我通过尝试动画 block 设法解决了这个问题。我移动了内容 View 行,它解决了问题

 [UIView animateWithDuration:0.25 animations:^{
_banner.frame = bannerFrame;
} completion:^(BOOL finished) {
_contentView.frame = contentFrame;
[self.view bringSubviewToFront:_banner];
}];

关于ios - iAd 涵盖了我对第一次加载的看法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26629059/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com