iOS如何植入admob广告
2013-04-10 17:17
411 查看
转自:http://blog.sina.com.cn/s/blog_6fe6da8301019cuv.html
具体做法可参见:https://developers.google.com/mobile-ads-sdk/docs/#incorporating
之后就要在项目中加入code. 登陆admob后可下载到例子程序:
1. 在.h中 声明变量 GADBannerView *adBanner_;
2. 导入框架MessageUK.framework, AudioToolbox.framework, systemConfiguration.framework
3. 在viewDidAppear(或者其他地方)加入如下代码:
CGPoint origin = CGPointMake(0.0, 0.0);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner =
[[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin] autorelease];
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
self.adBanner.adUnitID = kSampleAdUnitID;
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest: [GADRequest request]];
4. 如果有必要实现起delegate方法
#pragma mark GADBannerViewDelegate impl
// We've received an ad successfully.
- (void)adViewDidReceiveAd:(GADBannerView *)adView
{
NSLog(@"Received
ad successfully");
}
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed
to receive ad with error: %@", [error localizedFailureReason]);
}
5. 在build Setting中,将 Other
Linker Flags, add
both Debug and Release.
大功告成,运行程序就可以在屏幕上方看到admob广告了,这里的kSampleAdUnitID是你注册在admob注册程序后的Publisher ID
具体做法可参见:https://developers.google.com/mobile-ads-sdk/docs/#incorporating
之后就要在项目中加入code. 登陆admob后可下载到例子程序:
1. 在.h中 声明变量 GADBannerView *adBanner_;
2. 导入框架MessageUK.framework, AudioToolbox.framework, systemConfiguration.framework
3. 在viewDidAppear(或者其他地方)加入如下代码:
CGPoint origin = CGPointMake(0.0, 0.0);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner =
[[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin] autorelease];
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
self.adBanner.adUnitID = kSampleAdUnitID;
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest: [GADRequest request]];
4. 如果有必要实现起delegate方法
#pragma mark GADBannerViewDelegate impl
// We've received an ad successfully.
- (void)adViewDidReceiveAd:(GADBannerView *)adView
{
NSLog(@"Received
ad successfully");
}
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed
to receive ad with error: %@", [error localizedFailureReason]);
}
5. 在build Setting中,将 Other
Linker Flags, add
-ObjCto
both Debug and Release.
大功告成,运行程序就可以在屏幕上方看到admob广告了,这里的kSampleAdUnitID是你注册在admob注册程序后的Publisher ID
相关文章推荐
- iOS如何植入admob广告
- 如何使用PhoneGap程序将AdMob广告嵌入到你的HTML5 iOS游戏中
- 如何添加AdMob广告到现有的Unity3D ios游戏
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- iOS 如何在cocos2d Game中添加 AdMob 广告条
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- iOS开发-植入广告(iAd, Admob实例)
- iOS开发-植入广告(iAd, Admob实例)
- IOS如何植入广告
- iOS开发-植入广告(iAd, Admob实例)
- 如何添加AdMob广告到现有的Unity3D ios游戏
- iOS开发-植入广告(iAd, Admob实例)
- iOS中如何在欢迎界面中动态加载广告
- IOS版AdMob集成KeyMob广告教程
- iOS开发用swift添加admob广告
- Unity3d iOS 如何添加Admob
- Android应用开发:如何在App中植入广告?
- Cocos2d-x2.2使用Admob插屏广告教程(一):iOS篇