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

时间:2021-09-22 21:11:54

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.

如有任何帮助,我们将不胜感激。

4 个解决方案

#1


19  

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

更新-@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];

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

#2


2  

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:

为什么不使用adView的“center”属性呢?如果你的主要视图的尺寸是视图宽度和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

干杯

#3


0  

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

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

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

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

adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

adView。autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

#4


0  

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)

然后,使用故事板,忽略标准的iAd Banner视图不会到达屏幕的边缘。将iAd横幅设置为中心,然后将其移动到接近底部的位置。没有其他宽度设置(没有前置或后置设置)

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.

我的视图可以从超视图的底部得到8个像素,但是我在iAd横幅和UIController视图之间使用了像素。

#1


19  

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

更新-@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];

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

#2


2  

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:

为什么不使用adView的“center”属性呢?如果你的主要视图的尺寸是视图宽度和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

干杯

#3


0  

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

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

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

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

adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

adView。autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

#4


0  

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)

然后,使用故事板,忽略标准的iAd Banner视图不会到达屏幕的边缘。将iAd横幅设置为中心,然后将其移动到接近底部的位置。没有其他宽度设置(没有前置或后置设置)

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.

我的视图可以从超视图的底部得到8个像素,但是我在iAd横幅和UIController视图之间使用了像素。