views:

103

answers:

1

I have the following ADBannerViewDelegate implementations:

#pragma mark ADBannerViewDelegate Methods
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
    self.headerView.frame = CGRectMake(0, 0, 320, 94);
    [self.tableView setTableHeaderView:headerView];
    adBannerView.hidden = FALSE;
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    headerView.frame = CGRectMake(0, 0, 320, 50);
    [self.tableView setTableHeaderView:headerView]; //hide the ad if it doesnt fill
    adBannerView.hidden = TRUE;
}

If an ad is unavailable, I want to shrink my headerview. If there is an ad, I want to expand it.

This works fine, when the view loads. However, it seems like these delegate methods stop getting called after the view has loaded. I can possibly run into the following scenario:

  1. View A loads, but no iAd is available so headerView is shrunken
  2. User goes to View B
  3. User comes back to View A
  4. PROBLEM: View A has already loaded, so the headerView is shrunken, but the ADBannerViewDelegate methods aren't called, so I can't check to see if an ad is available

How can I make sure these delegate methods get called even after the view has been initially loaded?

A: 

Delegate methods do get called. Apple just sometimes serves no ads, so you get a chance to handle it.

Sheehan Alam