iOS 教程
- 第1节:IOS 简介
- 第2节:IOS 环境搭建
- 第3节:IOS Objective C 基础知识
- 第4节:IOS 创建第一款iPhone应用程序
- 第5节:IOS 操作(action)和输出口(Outlet)
- 第6节:IOS 委托(Delegates)
- 第7节:IOS UI元素
- 第8节:IOS 加速度传感器(accelerometer)
- 第9节:IOS 通用应用程序
- 第10节:IOS 相机管理
- 第11节:IOS 定位操作
- 第12节:IOS SQLite数据库
- 第13节:IOS 发送电子邮件
- 第14节:IOS 音频和视频(Audio & Video)
- 第15节:IOS 文件处理
- 第16节:IOS 地图开发
- 第17节:IOS 应用内购买
- 第18节:IOS 整合iAD
- 第19节:IOS GameKit
- 第20节:IOS 故事板(Storyboards)
- 第21节:IOS 自动布局
- 第22节:IOS Twitter和Facebook
- 第23节:IOS 内存管理
- 第24节:IOS 应用程序调试
IOS 整合iAD
简介
IAD是苹果推出的广告平台,它可以帮助开发者从应用程序中获取收入。
实例步骤
1. 创建一个简单的View based application
2. 选择项目文件,然后选择目标,然后选择框架并添加 iAd.framework。
3. 更新 ViewController.h 如下所示
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController<ADBannerViewDelegate>
{
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