Adding iAds to Cocos2d-x on iOS
http://www.mwebb.me.uk/2013/08/adding-iads-to-cocos2d-x-on-ios.html
Looking at the forums it seems a lot of people are having trouble getting iADs working on Cocos2d-x on iOS. It's actually pretty straight forward, but I guess a lot of people using Cocos2d-x aren't familiar with Objective C.
Here's a quick explaination.
First, you need to add the iADFramework your project (click your targer, got to Summary, find Link Frameworks and Libraries and add it).
Now you need to add the code. In project explore, expand the folder with the same name as your application, and you'll see a folder (or group) call iOS. In there is the AppController clash. This is the place you need to put the code.
First, in AppController.h
Add an import for iAds.
Now you need to make the class a delegate for ADBannerViewDelegate as it needs to response to callbacks.
So my interface declaration looks like this now:
OK - see it's got ADBannerViewDelegate at the end?
Now you need add you view to the header, and also a variable to keep track of whether your add is visible (as Apple with reject it if you don't hide non-filled iAD views)
So my header now looks like this:
OK, that's it for the header. Now go to the AppController.mm
Firstly, at the top, just under implementation, do your synthesising:
Now you need to create an ad banner, and add it to your root view controller. Find the lines:
That creates the viewController that you need to add your ad view to.
I want to add my add at the bottom, so this is the code I use:
The first three lines create the ad, and the last three move it off the bottom of the screen (as it's not got an ad yet, so it needs to be hidden. I'll leave you to work out how to change the code if you want it off the top.
IAds will call either 'BannerViewDidLoadAd' or 'didFailToRecieveAdWithError'. You need to respond to these, either by move the view onto the screen (if it loaded an ad) or moving it off it didn't (I know it's off the screen on the first call, but this may be a later ad). Add these at the bottom (just before @end)
That's all you have to do (other than enable iADs in iTunesConnect for your ad - that's pretty easy).
Remember to make sure your test device its connected to the net when you test otherwise nothing will happen!
Also, iADs test server often responds with errors - don't worry - this is normal.
Adding iAds to Cocos2d-x on iOS的更多相关文章
- 史上最全的常用iOS的第三方框架
文章来源:http://blog.csdn.net/sky_2016/article/details/45502921 图像: 1.图片浏览控件MWPhotoBrowser 实现了一个照片 ...
- IOS常用第三方开源类库&组件
1.AFNetworking AFNetworking 采用 NSURLConnection + NSOperation, 主要方便与服务端 API 进行数据交换, 操作简单, 功能强大, 现在许多人 ...
- 常用iOS的第三方框架
图像:1.图片浏览控件MWPhotoBrowser 实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等 ...
- iOS知名第三方框架和流行APP们所用的第三方框架小结
网易新闻AppleReachabilityASIHTTPRequestEGOTableViewPullRefreshGTMNSString+HTMLMGTemplateEngineMPOAuthReg ...
- Delphi IOS环境安装
RAD Delphi XE/10 Seattle 安装IOS.OSX环境安装,IOS模拟器,MAC X 真机可以调试 http://community.embarcadero.com/blogs/en ...
- iOS开发——网络编程Swift篇&(八)SwiftyJSON详解
SwiftyJSON详解 最近看了一些网络请求的例子,发现Swift在解析JSON数据时特别别扭,总是要写一大堆的downcast(as?)和可选(Optional),看?号都看花了.随后发现了这个库 ...
- iOS第三方开源库的吐槽和备忘(转)
原文:http://www.cocoachina.com/industry/20140123/7746.html 做iOS开发总会接触到一些第三方库,这里整理一下,做一些吐槽. 目前比较活跃的社区 ...
- Cocos2d中update与fixedUpdate的区别(六)
它如何工作呢? update:和fixedUpdate:方法实际这样工作. Cocos2D将从iOS接口中取得时间间隔(delta)在你的游戏代码执行期间,并且检查fixedUpdate:方法在间隔期 ...
- iOS开发-常用第三方开源框架介绍(你了解的ios只是冰山一角)--(转)
图像: 1.图片浏览控件MWPhotoBrowser 实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作. 下 ...
随机推荐
- (转) mysql数据库引擎:MyISAM和InnoDB(性能优化)
转自 http://yuwensan126.iteye.com/blog/1138022 Mysql 数据库中,最常用的两种引擎是innordb和myisam.Innordb的功能要比myiasm强大 ...
- Parallel for-each loops in .NET C# z
An IEnumerable object An Action of T which is used to process each item in the list List<string&g ...
- 【Jenkins】linux下Jenkins集成ant进行编译并发送结果
三个文章吧: 1 如何使用ant编译执行jmeter测试用例,并生成html报告 2 如何在Linux下搭建jenkins环境. 3 如何在Linux下搭建的jenkins中执行ant构建运行,并发送 ...
- Web网站常规测试方法
功能测试 1. 安装测试: 安装过程中对于缺省安装目录及任意指定的安装目录,是否都能正确安装: 若是选择安装,查看能否实现其相应的功能: 在所有能中途退出安装的位置退出安装程序后,验证此程序并未安装成 ...
- Linux Vi 删除全部内容,删除某行到结尾,删除某段内容 的方法
1.打开文件 vi filename 2.转到文件结尾 G 或转到第9行 9G 3.删除所有内容(先用G转到文件尾) ,使用: :1,.d 或者删除第9行到第200行的内容(先用200G转到第200行 ...
- Mac安装wget的两种方法
第一种.传统的安装包 A - 从ftp://ftp.gnu.org/gnu/wget/下载到最新的wget安装包到本地 B - 然后通过终端tar -zxvf命令解压到我们某个目录 C - 然后依 ...
- 洛谷 P1169 [ZJOI2007]棋盘制作
2016-05-31 14:56:17 题目链接: 洛谷 P1169 [ZJOI2007]棋盘制作 题目大意: 给定一块矩形,求出满足棋盘式黑白间隔的最大矩形大小和最大正方形大小 解法: 神犇王知昆的 ...
- CM 部署bigdata测试环境群集机器报错
CM repo库info;
- Java for循环的几种用法详解
本文非常适合初学Java的程序员,主要是来了解一下Java中的几种for循环用法,分析得十分详细,一起来看看. J2SE 1.5提供了另一种形式的for循环.借助这种形式的for循环,可以用更简单地方 ...
- PCb过孔大小设置 / 丝印层字符尺寸设置
PCb过孔大小一般设置为:内孔(孔尺寸)0.30(12mil),外壳(直径)0.6(24mil) 常用过孔设置: 内径: 15mil(0.381mm) 30mil(0.762mm) 外径: 20mi ...