The Easiest Way to Add an Add Banner onto iOS App

  • Thursday, May 2, 2013
  • Posted by filial23
  • Labels:


  1. Add iAd.framework into your target.
  2. Move on to the storyboard and place an Ad BannerView object on an arbitrary view. Set its alpha value 0.0 to avoid displaying the white ad area before it's loaded.


  3. Make a connection to the field by pressing the control button and dragging a connection line to the .h file at the same time.

  4. After releasing the mouse button on the .h file, the popup appears to enter the connection's name.

  5. After entering the connection's name, move on to the .m file corresponding to the .h file.
  6. Implement two AdBannerViewDelegate protocols as following. When the ad is loaded, the ad banner appears gradually. When the ad is not loaded, the ad banner disappears gradually. Your can trust the below code because the app including the following code has been approved by Apple.
    - (void)bannerViewDidLoadAd:(ADBannerView *)banner
    {
        if (banner.hidden) {
            banner.alpha = 0.0;
            banner.hidden = NO;
            [UIView animateWithDuration:0.5
                             animations:^{
                                 banner.alpha = 1.0;
                             }];
        }
    }

    - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
    {
        if (!banner.hidden) {
            [UIView animateWithDuration:0.5
                             animations:^{
                                 banner.alpha = 0.0;
                             }
                             completion:^(BOOL finished) {
                                 banner.hidden = YES;
                             }];
        }
    }

1 comments:

  1. The name of the connection is not "adBannerView" but "banner".

Post a Comment