做(zuò)自(zì)由與創造的先行(xíng)者

iOS整合iAD

iOS開(kāi)發手冊

IOS iAD整合

簡介

IAD是蘋果推出的廣告平台,它可(kě)以幫助開(kāi)發者從(cóng)應用程序中獲取收入。

實例步驟

1. 創建一(yī)個簡單的View based application

2. 選擇項目文件,然後選擇目标,然後選擇框架并添加 iAd.framework。

3. 更新 ViewController.h 如(rú)下(xià)所示

#import

#import

@interface ViewController : UIViewController

{

ADBannerView *bannerView;

}

@end

4. 更新ViewController.m ,如(rú)下(xià)所示

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad

{

[super viewDidLoad];

bannerView = [[ADBannerView alloc]initWithFrame:

CGRectMake(0, 0, 320, 50)];

// Optional to set background color to clear color

[bannerView setBackgroundColor:[UIColor clearColor]];

[self.view addSubview: bannerView];

}

- (void)didReceiveMemoryWarning

{

[super 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

網站建設開(kāi)發|APP設計開(kāi)發|小程序建設開(kāi)發
下(xià)一(yī)篇:iOS應用內(nèi)購買
上(shàng)一(yī)篇:iOS定位操作(zuò)