Reputation: 11297
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.
Upvotes: 5
Views: 9379
Reputation: 650
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.
Upvotes: 0
Reputation: 110
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
Upvotes: 2
Reputation: 3653
This is what helped me move the view to the bottom:
adFrame.origin.y = self.view.frame.size.height;
adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
Upvotes: 0
Reputation: 10296
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];
Upvotes: 18