iphone iads动画

时间:2011-02-08 11:40:19

标签: iphone

大家好我正在研究iAds。我希望在广告更改时为广告横幅设置动画。有没有办法让它们自动动画?或者我们应该在广告每次更改时手动执行此操作。

1 个答案:

答案 0 :(得分:1)

标准技术是在屏幕外创建iAd横幅,等待iAd横幅广告成功收到广告的通知,然后将其从屏幕外显示到屏幕上。同样,如果收到广告时出错,请将广告横幅从屏幕设置为屏幕外设置,直到成功收到新的广告。

像这样:

- (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;
    }
}