I am using Auto Layout in my iOS 7 project with the following view hierarchy
Main page
-Container view
--- Button
--- Button
--- ImageView
-Banner View (iAd Banner View)
Main View and Container View - full screen width and height. I have horizontal and vertical spatial limitations in the container view, attached to the main view (screen height and width). Also, the Container View sub-items are limited to the view button with a 20px space.
My problem arises when the Banner View is finally filled and placed at the bottom of the screen, after which I have a container view that subtracts the banner viewing height from its frame height to allow space for viewing the banner. (code used below). The ideal result is to look at the container to subtract the height and update the restrictions on subviews based on this new height, but ultimately this means that iAD Banner View simply overlays the view, as shown in the figure.
Code for BannerViewDidLoadAd:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner { CGRect contentFrame = self.containerView.bounds; CGRect bannerFrame = self.bannerView.bounds; if (self.bannerView.bannerLoaded) { contentFrame.size.height = self.containerView.frame.size.height - self.bannerView.frame.size.height; bannerFrame.origin.y = contentFrame.size.height;; } else { bannerFrame.origin.y = contentFrame.size.height; } [UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{ [self.containerView setFrame:contentFrame]; [self.containerView layoutIfNeeded]; self.bannerView.frame = bannerFrame; self.bannerView.hidden = NO; }]; [self.containerView updateConstraints]; }
Image of iAd overlaying Container View and its SubViews

ios objective-c autolayout ios7 iad
William smith
source share