Admob广告的添加
来源:互联网 发布:ubuntu设置ip不起作用 编辑:程序博客网 时间:2024/04/28 16:04
admon广告添加的步骤和注意事项:
1、首先下载admob的API,主要包括下图中的文件
2、直接加载到程序中
3、添加以下几个依赖库
SystemConfiguration.framwork
MessageUI.framework
AdSupport.framework
storeKit.framework
4、在viewcontroller中添加
-(void)addAdMob{ CGSize size = self.view.frame.size; myBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait] autorelease]; //指定广告的“单位标识符”。这是您的AdMob的发布者 myBanner.frame = CGRectMake(size.width/2 - myBanner.frame.size.width/2,size.height-myBanner.frame.size.height, myBanner.frame.size.width,myBanner.frame.size.height); myBanner.adUnitID = @"a1515917b09dbda"; myBanner.rootViewController = self; [self.view addSubview:myBanner]; // Initiate a generic request to load it with an ad. GADRequest *request = [GADRequest request]; #if TARGET_IPHONE_SIMULATOR request.testing = YES;#endif NSLog(@"loadRequest start"); [myBanner loadRequest:request]; NSLog(@"loadRequest end");}
如果是用cocos2d
-(void)addAdMob{ CGSize size = [[CCDirector sharedDirector] winSize]; myBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait] autorelease]; //指定广告的“单位标识符”。这是您的AdMob的发布者 myBanner.frame = CGRectMake(size.width/2 - myBanner.frame.size.width/2,size.height-myBanner.frame.size.height, myBanner.frame.size.width,myBanner.frame.size.height); myBanner.adUnitID = @"a1515917b09dbda"; AppController *appDelegate = (AppController*) [[UIApplication sharedApplication] delegate]; [myBanner setRootViewController:[appDelegate navController]]; [[CCDirector sharedDirector].view addSubview:myBanner]; // Initiate a generic request to load it with an ad. GADRequest *request = [GADRequest request]; #if TARGET_IPHONE_SIMULATOR request.testing = YES;#endif NSLog(@"loadRequest start"); [myBanner loadRequest:request]; NSLog(@"loadRequest end");}
5、在初始化函数中,添加[self addmob]6、设置编译选项,如图
好了,现在应该可以正常运行了,如果仍有问题,请查看官方说明
https://developers.google.com/mobile-ads-sdk/docs/admob/mediation#ios-linker
- Admob广告的添加
- Admob插页广告的添加
- Cocos2dx---------------------添加Admob广告
- AdMob广告添加方法
- android 中添加 admob 广告
- android添加广告之--admob
- Android中添加Admob广告
- android添加广告之--admob
- Android中添加Admob广告
- phonegap 添加admob广告教程
- ionic添加admob广告教程
- cocos2dx添加Admob广告中遇到的问题
- unity添加admob广告过程遇到的问题
- 如何添加AdMob广告到现有的Unity3D ios游戏
- 如何添加AdMob广告到现有的Unity3D ios游戏
- 如何添加AdMob广告到现有的Unity3D ios游戏
- 使用Admob给Android APP添加广告
- IOS Cocos2dx 添加Admob 广告错误
- SQL时间重合 包含 交叉
- jquery中判断input元素为空和 mysql中的编码
- 工作流管理软件之业务表单实现方法
- jQuery20种过滤器
- 【网络流第一步】Hdu 1532——Drainage Ditches
- Admob广告的添加
- dm365 codecs 输入输出格式
- 设计模式-极品飞车-【观察者模式】
- vs2005 和 VAssistX 常用快捷键
- 运行时类的实例的动态创建
- 14步完成SharePointServer2010企业版安装
- jQuery属性选择器
- jQuery操作HTML和CSS
- 软件体系结构的重构——定义