如何让我的 iAd 横幅出现在屏幕底部?

发布于 2024-12-13 12:58:12 字数 403 浏览 2 评论 0原文

我有以下代码,允许我将其放置在顶部。我希望它出现在底部。

 adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
 adView.frame = CGRectOffset(adView.frame, 0, -50);
 adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
 adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
 [self.view addSubview:adView];

任何帮助将不胜感激。

I have the following code that allows me to position it on the top. I am wanting it to appear at the bottom.

 adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
 adView.frame = CGRectOffset(adView.frame, 0, -50);
 adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
 adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
 [self.view addSubview:adView];

Any assistance will be appreciated.

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

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

发布评论

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

评论(4

混浊又暗下来 2024-12-20 12:58:12

更新 — @larsacus 指出这是针对 4.2+ 的:

adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
[self.view addSubview:adView];

显示在模拟器中工作

Update—@larsacus pointed out this is for 4.2+:

adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
[self.view addSubview:adView];

Shown working in simulator

妳是的陽光 2024-12-20 12:58:12

我的第一个答案:)

为什么不使用 adView 的“center”属性?如果主视图的尺寸是 viewWidth 和 viewHeight:

//at the bottom of view,centered
adView.center=CGPointMake(viewWidth/2, viewHeight-adView.frame.size.height);

//at the top, right corner ;)
adView.center=CGPointMake(viewWidth-adView.frame.size.width/2, adView.frame.size.height);

干杯

My first answer on SO :)

Why not use the 'center' property of the adView? If the dimensions of your main view are viewWidth and viewHeight:

//at the bottom of view,centered
adView.center=CGPointMake(viewWidth/2, viewHeight-adView.frame.size.height);

//at the top, right corner ;)
adView.center=CGPointMake(viewWidth-adView.frame.size.width/2, adView.frame.size.height);

Cheers

々眼睛长脚气 2024-12-20 12:58:12

这帮助我将视图移动到底部:

adFrame.origin.y = self.view.frame.size.height;

adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

This is what helped me move the view to the bottom:

adFrame.origin.y = self.view.frame.size.height;

adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

陌路终见情 2024-12-20 12:58:12

然后,使用故事板时,请忽略标准 iAd 横幅视图未到达屏幕边缘的情况。
将 iAd 横幅设置为居中,然后将其移动到您想要的尽可能靠近底部的位置。没有其他宽度设置(没有前导或尾随设置),

我的看起来不错,距超级视图底部 8 像素,但我选择了 - iAd 横幅和 UIController 视图之间的像素。

Using Storyboards, then, ignore that the standard iAd Banner View does not reach the edges of the screen.
Set the iAd banner to be centred, then move it to as close to the bottom as you want. No other width settings (no leading or trailing settings)

Mine looked ok with 8 pixels from the bottom of the superview, but I went with - pixels between the iAd banner and the UIController View.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文