Why are my iAds not displaying in the iPhone Simulator in iOS 4.1?

iAd is for iOS 4.0 and above, so 4.1 should be fine.

Did you miss one of the step below…

  • Add iAd.framework to your project
  • #import <iAd/iAd.h> in your view controller .h file
  • Drag and drop iAdBannerView to your interface
  • Link adView variable and delegate using the interface builder
  • Implement the delegate bannerViewDidLoadAd that show the ad
  • Implement the delegate didFailToReceiveAdWithError that hide the ad

You can see the code below and adapt to your own need…

// RootView.h

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface RootView : UIViewController {
    BOOL bannerIsVisible;
    ADBannerView *adView;
}

@property (nonatomic) BOOL bannerIsVisible;
@property (nonatomic, retain) IBOutlet ADBannerView *adView;

@end
// RootView.m

#pragma mark -
#pragma mark iAd Banner

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {

    YourAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    UINavigationController *navigationController = (UINavigationController *)[appDelegate navigationController];

    if (self.bannerIsVisible == NO) {
        banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
        [navigationController view].frame = CGRectMake(0, 0, 320, 410);
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

    YourAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    UINavigationController *navigationController = (UINavigationController *)[appDelegate navigationController];

    if (self.bannerIsVisible) {
        banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
        [navigationController view].frame = CGRectMake(0, 0, 320, 460);
        self.bannerIsVisible = NO;
    }
}