开发手册 欢迎您!
软件开发者资料库

iOS - iAd集成

iOS iAd集成 - 在iOS上学习iPhone和iPad应用程序开发,从简单和简单的步骤开始,从基本到高级概念,包括入门,环境设置,Objective-C,首个iPhone应用程序,操作和插座,代表,UI元素,加速度计,通用应用程序,相机管理,位置处理,SQLite数据库,发送电子邮件,音频和视频,文件处理,访问地图,应用程序内购买,iAd集成,GameKit,故事板,自动布局,Twitter和Facebook,内存管理,应用程序调试。

iAd用于显示由Apple服务器提供的广告. iAd帮助我们从iOS应用程序中获得收入.

iAd集成 - 涉及的步骤

第1步 : 创建一个简单的基于视图的应用程序.

第2步 : 选择项目文件,然后选择目标,然后在选择框架中添加iAd.framework.

步骤3 : 更新ViewController.h如下 :

#import #import @interface ViewController : UIViewController {   ADBannerView *bannerView;}@end

第4步 : 更新 ViewController.m 如下 :

#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

输出

当我们运行应用程序时,我们会得到以下输出 :

iOS Tutorial