In both cases, you add 50.0px to banner.frame.origin.y .
In any case: even if you subtract 50.px in didFailToReceiveAdWithError: it may happen that didFailToReceiveAdWithError: is called several times in and your code can move the banner higher and higher (-50.0, -100.0, -150.0 ...) .
So itβs better to rigidly set hidden and visible positions, rather than calculate them.
Try the following:
- (void)bannerView:(ADBannerView *)abanner didFailToReceiveAdWithError:(NSError *)error { if (self.bannerIsVisible) { [UIView beginAnimations:@"animateAdBannerOff" context:NULL]; banner.frame = CGRectMake(0.0,-50.0,banner.frame.size.width,banner.frame.size.height); [UIView commitAnimations]; self.bannerIsVisible = NO; } } - (void)bannerViewDidLoadAd:(ADBannerView *)abanner { if (!self.bannerIsVisible) { [UIView beginAnimations:@"animateAdBannerOn" context:NULL]; banner.frame = CGRectMake(0.0,0.0,banner.frame.size.width,banner.frame.size.height); [UIView commitAnimations]; self.bannerIsVisible = YES; } }
source share