/*
转自: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 -ObjC to both Debug and Release.
大功告成,运行程序就可以在屏幕上方看到admob广告了,这里的kSampleAdUnitID是你注册在admob注册程序后的Publisher ID
更多 0
*/