Hi all I am working on the iAds. I want to animate the ad banner when the ad changes. Is there any way to make them animate automatically? or is it th开发者_运维百科at we should do it manually each time the ad changes.?
The standard technique is to create the iAd banner off-screen, wait for notification that the iAd banner has successfully received an ad, then to animate it from off-screen to on-screen. Likewise, if there was an error in receiving the ad, animate the ad banner from on-screen to off-screen, until a new add is successfully received.
Like this:
- (void)bannerView:(ADBannerView *)banner
didFailToReceiveAdWithError:(NSError *)error
{
if (self.isBannerVisible)
{
CGFloat yCoord = ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) ? 1024.0 : 480.0;
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
banner.frame = CGRectMake( 0, yCoord, banner.frame.size.width, banner.frame.size.height );
[UIView commitAnimations];
self.isBannerVisible = NO;
}
}
-(void) bannerViewDidLoadAd:(ADBannerView *)banner {
if (!self.isBannerVisible)
{
CGFloat yCoord = ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) ? 1024.0 - banner.frame.size.height : 480.0 - banner.frame.size.height;
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
banner.frame = CGRectMake( 0, yCoord, banner.frame.size.width, banner.frame.size.height );
[UIView commitAnimations];
self.isBannerVisible = YES;
}
}
精彩评论