iOS如何植入admob广告
2013-12-06 23:18
363 查看
具体做法可参见: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 -ObjC to both Debug and Release.
大功告成,运行程序就可以在屏幕上方看到admob广告了,这里的kSampleAdUnitID是你注册在admob注册程序后的Publisher
ID
之后就要在项目中加入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 -ObjC to both Debug and Release.
大功告成,运行程序就可以在屏幕上方看到admob广告了,这里的kSampleAdUnitID是你注册在admob注册程序后的Publisher
ID
相关文章推荐
- iOS如何植入admob广告
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- iOS 如何在cocos2d Game中添加 AdMob 广告条
- IOS 如何在cocos2d Game中添加 AdMob 广告条
- iOS开发-植入广告(iAd, Admob实例)
- IOS如何植入广告
- iOS开发-植入广告(iAd, Admob实例)
- 如何添加AdMob广告到现有的Unity3D ios游戏
- 如何使用PhoneGap程序将AdMob广告嵌入到你的HTML5 iOS游戏中
- iOS开发-植入广告(iAd, Admob实例)
- iOS开发-植入广告(iAd, Admob实例)
- 如何添加AdMob广告到现有的Unity3D ios游戏
- iOS 10下的In-Apps视频广告,如何更好获取优质流量
- 在android应用中植入Admob广告赚钱
- admob 广告代码参考 iOS 弹窗广告
- ios植入广告
- Cocos2d-x2.2使用Admob插屏广告教程(一):iOS篇
- admob 广告代码参考 iOS banner广告
- 如何在 android 程序中加入 admob 广告