Search code examples
iphonexcodeuiviewadbannerview

Move ADBannerView off screen?


Yes, I've seen the other question and they are of no help. So I want to move the iAD banner off of my view. It's on the iphone, at the top of the screen on portrait view. Here is my code. Where am I going wrong here?

//Move the banner off the screen.
- (void)moveBannerViewOffScreen
{
   if (self.bannerView.isHidden == NO)
   {
       [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
       bannerView.frame = CGRectOffset(bannerView.frame, 0, bannerView.frame.size.height);
       [UIView commitAnimations];
       self.bannerView.hidden = YES;
   }    
}

//Move the banner on the screen.
- (void)moveBannerOnScreen
{
   if (self.bannerView.isHidden ==YES)
   {
       [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
       bannerView.frame = CGRectOffset(bannerView.frame, 0, -bannerView.frame.size.height);
       [UIView commitAnimations];
       self.bannerView.hidden = NO;
   }
}

Solution

  • Better you can change code in "moveBannerViewOffScreen" for iphone like this

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:bannerView cache:YES];
    bannerView.frame = cgRectMake(0,-50,50,320);
    [UIView commitAnimations];
    

    in"moveBannerViewOnScreen"

     [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:bannerView cache:YES];
    bannerView.frame = cgRectMake(0,0,50,320);
    [UIView commitAnimations];