I'm using the following code to setup a VC that can display banner ads
[self setCanDisplayBannerAds:YES];
The problem I'm having is that I would like to display text at the very bottom of my application unless of course a banner ad appears in which case I would place the text on top of the banner. I can't seem to find a delegate method that is called or any other way to make this happen using setCanDisplayBannerAds. Am I missing something simple here?
I've found my answer.
When you set canDisplayBannerAds:YES on a view controller Apple takes control of self.view and moves your view to self.originalContentView. Therefore if you want to align this to the bottom of the view you simple add a constraint using the originalContentView.
When a banner shows and hides Apple adjusts the dimensions of your originalContentView which will result in the layout being redrawn.
The code below will align viewYouWantOnTheBottom to the bottom of the view when there is no ad and will place it right on top of the banner when the ad displays.
I hope this helps someone.
[self.originalContentView addConstraint:[NSLayoutConstraint constraintWithItem:viewYouWantOnTheBottom attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.originalContentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];