实现步骤:
1. 创建一个简单的View based application
2. 选择框架并添加 iAd.framework。
3. 代码如下所示:
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController<ADBannerViewDelegate>
{
ADBannerView * bannerView;
}
@end
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
bannerView = [[ADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
[bannerView setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:bannerView];
}
//#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");
//
//}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
ok,完成收工
本文介绍如何在iOS应用中集成iAd广告框架,并提供详细的步骤指导,包括创建项目、添加iAd.framework以及实现广告展示的代码示例。
2102

被折叠的 条评论
为什么被折叠?



