0

I have implemented AdBannerView on a view controller in my app. It works fine on iPhone, but when testing on iPad there is a problem. The ad shows up fine, but when I turn off wifi to test the dismissal, the ad takes all the elements inside the window down with it and leaves the background and tabbar in place. This only happens on iPad.

Here is my code for animating the ad view:

- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation {
int adY = 432;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    adY = 955;
}
if (_adBannerView != nil) {        
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        [_adBannerView setCurrentContentSizeIdentifier:
         ADBannerContentSizeIdentifierLandscape];
    } else {
        [_adBannerView setCurrentContentSizeIdentifier:
         ADBannerContentSizeIdentifierPortrait];
    }          
    [UIView beginAnimations:@"fixupViews" context:nil];
    if (_adBannerViewIsVisible) {
        NSLog(@"Visible");
        CGRect adBannerViewFrame = [_adBannerView frame];
        adBannerViewFrame.origin.x = 0;
        adBannerViewFrame.origin.y = adY -
        [self getBannerHeight:toInterfaceOrientation];

        [_adBannerView setFrame:adBannerViewFrame];
        CGRect contentViewFrame = _contentView.frame;

        contentViewFrame.origin.y = adY +
        [self getBannerHeight:toInterfaceOrientation];

        contentViewFrame.size.height = self.view.frame.size.height - 
        [self getBannerHeight:toInterfaceOrientation];

        _contentView.frame = contentViewFrame;

    } else {
        NSLog(@"Not Visible");
        CGRect adBannerViewFrame = [_adBannerView frame];
        adBannerViewFrame.origin.x = 0;
        adBannerViewFrame.origin.y = adY;

        [_adBannerView setFrame:adBannerViewFrame];
        CGRect contentViewFrame = _contentView.frame;

        contentViewFrame.origin.y = adY
        + [self getBannerHeight:toInterfaceOrientation];

        contentViewFrame.size.height = self.view.frame.size.height;

        _contentView.frame = contentViewFrame;            
    }
    [UIView commitAnimations];
}   

}

Nungster
  • 726
  • 8
  • 28

1 Answers1

0

I had my offset frame of the ad view in the wrong location. It so happened to be perfect for an iPhone frame that as the adview was created was enough to push the ad in the right place. When it came time for the iPad, The offset calculated pushed the view off the window but not enough to come back into view.

Nungster
  • 726
  • 8
  • 28