How to make an iAd banner at the bottom of the screen?

I have the following code that allows me to position it on top. I want him to appear below.

 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 help would be appreciated.

+5
source share
4 answers

Update- @ larsacus pointed out that 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

+19
source

My first answer to SO :)

Why not use the "center" property for 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);

Greetings

+2
source

:

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

adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

0

, , iAd Banner View . iAd , . ( )

Mine looked fine with 8 pixels from the bottom of the supervisor, but I went with - pixels between the iAd banner and the UIController view.

0
source

All Articles