本文主要是介绍iOS 广告平台 iAD整合,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
实现步骤:
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整合的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!