YouTip LogoYouTip

Ios Iad

iOS Integration with iAD | Novice Tutorial

Novice Tutorial -- Learning Technology and Dreams!

iOS Tutorial

iOS Tutorial iOS Introduction iOS Environment Setup Objective C Basics Create Your First iPhone Application iOS Actions and Outlets iOS - Delegates iOS UI Elements iOS Accelerometer iOS Universal Applications iOS Camera Management iOS Location Operations iOS SQLite Database iOS Sending Email iOS Audio and Video iOS File Handling iOS Map Development iOS In-App Purchase iOS Integration with iAD iOS GameKit iOS Storyboards iOS Auto Layouts iOS Twitter and Facebook iOS Memory Management iOS Application Debugging

iOS In-App Purchase iOS GameKit

IOS iAD Integration


Introduction

IAD is an advertising platform launched by Apple that can help developers generate revenue from applications.

Example Steps

  1. Create a simple View based application
  2. Select the project file, then select the target, then select frameworks and add iAd.framework.
  3. Update ViewController.h as shown below
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface ViewController : UIViewController<ADBannerViewDelegate>
{
    ADBannerView *bannerView;
}
@end
  1. Update ViewController.m as shown below
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    ;
    bannerView = [initWithFrame: CGRectMake(0, 0, 320, 50)];
    // Optional to set background color to clear color
    [bannerView setBackgroundColor:];
    [self.view addSubview: bannerView];
}

- (void)didReceiveMemoryWarning {
    ;
    // Dispose of any resources that can be recreated.
}

#pragma mark - AdViewDelegates

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    NSLog(@"Error loading");
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    NSLog(@"Ad loaded");
}

-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
    NSLog(@"Ad will load");
}

-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
    NSLog(@"Ad did finish");
}

@end

Output

Run the application and get the following output:

Image 2: iAdOutput

← Ios GamekitIos In App Purchase β†’