加载视图时的AdBanner空白区域

时间:2013-03-23 20:42:15

标签: iphone ios xcode adbannerview

我在UIView上有一个广告横幅,它在首次加载视图时显示空白区域。我

已经实现了委托方法,并且它们被调用并且横幅正常工作。它是

当视图最初加载并且广告第一次失败时,应用会显示

空格和委托方法不会被调用。 Anyone encountered this?

1 个答案:

答案 0 :(得分:0)

// Step 1 : add iAd.framework to your project
// Step 2 : #import <iAd/iAd.h>
// Step 3 : ADBannerViewDelegate to your viewController
// Step 4 : Initialize your adBanner in your viewDidLoad Method
    myIad = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
    [myIad setFrame:CGRectMake(0, self.view.frame.size.height, myIad.frame.size.width, myIad.frame.size.height)];
    [myIad setDelegate:self];

// Step 5 : Implement following Delegate method to show and hide your bannerView

#pragma mark - AdBanner Delegate
- (void)bannerViewWillLoadAd:(ADBannerView *)banner
{
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    // Show Add Banner
    [UIView animateWithDuration:0.25f animations:^{
        [banner setFrame:CGRectMake(0, self.view.frame.size.height-banner.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
    }];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    // Hide with animation as failed to load ad
    [UIView animateWithDuration:0.25f animations:^{
        [banner setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
    }];
}