Banner Ads

To load a banner, create a BIDBannerView and add it as a subview of your view hierarchy.

You can create banners of either 320x50 or 300x250 size:

#pragma mark - add banners to view

-(void)addBanner_320x50_to_view:(UIView*)view
{
    BIDBannerView* banner = [BIDBannerView bannerWithFormat:[BIDAdFormat banner_320x50] delegate:(id)self];
    banner.center = CGPointMake(CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds));
    [view addSubview:banner];
}

-(void)addBanner_300x250_to_view:(UIView*)view
{
    BIDBannerView* banner = [BIDBannerView bannerWithFormat:[BIDAdFormat banner_300x250] delegate:(id)self];
    banner.center = CGPointMake(CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds));
    [view addSubview:banner];
}

Implement BIDBannerViewDelegate so that you are notified of when your ad is ready and of other ad-related events.

#pragma mark - BIDBannerViewDelegate protocol methods

- (void)bannerDidDisplay:(BIDBannerView *)banner adInfo:(BIDAdInfo *)adInfo
{
    NSLog(@"Banner - did display ad. BannerView: %@, AdInfo: %@", banner, adInfo);
}

- (void)bannerDidFailToDisplay:(BIDBannerView *)banner adInfo:(BIDAdInfo *)adInfo error:(NSError *)error
{
    NSLog(@"Banner - did fail to display ad. BannerView: %@, Error: %@", banner, error);
}

- (void)bannerDidClick:(BIDBannerView *)banner adInfo:(BIDAdInfo *)adInfo
{
    NSLog(@"Banner - did click. BannerView: %@, AdInfo: %@", banner, adInfo);
}

- (void)allNetworksFailedToDisplayAdInBanner:(BIDBannerView *)banner
{
    NSLog(@"Banner - allNetworksFailedToDisplayAdInBanner: %@", banner);
}

//This method is called by the auto-load algorithm only. It is not called during refresh or autorefresh.
- (void)bannerDidLoad:(BIDBannerView *)banner adInfo:(BIDAdInfo *)adInfo
{
    NSLog(@"Banner - did load ad. BannerView: %@, AdInfo: %@", banner, adInfo);
}

Stopping and Starting Auto-Refresh

There may be cases when you would like to stop auto-refresh, for instance, when you hide a banner ad or want to manually refresh.

Stop auto-refresh for a banner ad with the following code:

[bidBannerView stopAutorefresh];

Start auto-refresh for a banner ad with the following code:

[bidBannerView startAutorefresh:30.0];

Manually refresh the contents with the following code. You must stop auto-refresh prior to calling refreshAd.

[bidBannerView refreshAd];

Stopping and Starting Auto-Load

By default, banners preload ads before any refresh attempt. So it is possible for a banner to use already preloaded ads instead of loading new ads during refresh attempts. To disable this feature you need to call the following method:

bidBannerView.autoload = NO;

Last updated