怎样设置admob的广告 ios

怎样设置admob的广告 ios,第1张

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广告

1.首先需要一个mac计算机安装碰森凳unity(如果你本身就是用mac开发就跳过打包package的步骤) 2.将你要导出的项目打包成package到该计算机之后,选择IOS发布环境并bulid 3.bulid完成后会生成一个Xcode文笑旅件,用Xcode将其打开并配置好相关的春搜信息(如版本。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12400794.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存