iAd View 与自定义 ViewController

发布于 2024-12-11 13:46:30 字数 893 浏览 3 评论 0原文

我尝试将 iAd 集成到我的应用程序中。

我有一个类 SwitchViewController (: UIViewController) ,它处理所有 自定义 ViewController 和我在此应用程序中拥有的视图。

当在最高 atIndex 添加如下视图时,出现错误:

ADBannerView: WARNING A banner view has an ad but may be obscured

但是,如果我不插入所有其他子视图 - iAd 工作正常。我可以看到它,但是 当然,所有其他观点都消失了。

有什么想法吗?

通过以下方式添加子视图:

ADBannerView *tmpBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
self.adView_iPad = tmpBannerView;
self.adView_iPad.frame = CGRectMake(0, 0, self.adView_iPad.frame.size.width, self.adView_iPad.frame.size.height);
self.adView_iPad.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
self.adView_iPad.delegate = self;
[self.view insertSubview:self.adView_iPad atIndex:100];

I try to integrate iAd to my App.

I have a class SwitchViewController (: UIViewController) which deals with all the
custom ViewControllers & Views I have in this app.

When adding the View as below at the highest atIndex, I get an error:

ADBannerView: WARNING A banner view has an ad but may be obscured

However, if I do not insert all the other subviews - the iAd works fine. I can see it, but
of course all the other views are gone.

Any Ideas?

Adding the subview by:

ADBannerView *tmpBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
self.adView_iPad = tmpBannerView;
self.adView_iPad.frame = CGRectMake(0, 0, self.adView_iPad.frame.size.width, self.adView_iPad.frame.size.height);
self.adView_iPad.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
self.adView_iPad.delegate = self;
[self.view insertSubview:self.adView_iPad atIndex:100];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断爱 2024-12-18 13:46:31

您始终希望确保 ADBannerView 是层次结构中的最顶层视图,以避免出现此警告。如果任何视图与它重叠,即使它具有透明度,您也会收到此警告。

你可以简单地做这样的事情。

ADBannerView *adView = <create the view>;
[superView addSubview:adView];
[superView bringSubviewToFront:adView];

更新:

设置视图大小时,最好查询类的大小。

+ (CGSize)sizeFromBannerContentSizeIdentifier:(NSString *)contentSizeIdentifier

这将返回您应该使用的高度和宽度。所以像这样设置框架:

CGSize size = [ADBannerView sizeFromBannerContentSizeIdentifier: ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.frame = CGRectMake(0, 0, size.width, size.height);

You always want to make sure the ADBannerView is the topmost view in the hierarchy to avoid this warning. If any view overlaps it, even if it has transparency, you'll get this warning.

You can simply do something like this.

ADBannerView *adView = <create the view>;
[superView addSubview:adView];
[superView bringSubviewToFront:adView];

UPDATE:

When setting the view size, it is best to query the class for the size.

+ (CGSize)sizeFromBannerContentSizeIdentifier:(NSString *)contentSizeIdentifier

This will return the height and width that you should use. So set the frame like this:

CGSize size = [ADBannerView sizeFromBannerContentSizeIdentifier: ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.frame = CGRectMake(0, 0, size.width, size.height);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文