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 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作. 下 ...
随机推荐
- 【原创】batch-GD, SGD, Mini-batch-GD, Stochastic GD, Online-GD -- 大数据背景下的梯度训练算法
机器学习中梯度下降(Gradient Descent, GD)算法只需要计算损失函数的一阶导数,计算代价小,非常适合训练数据非常大的应用. 梯度下降法的物理意义很好理解,就是沿着当前点的梯度方向进行线 ...
- 单点登录系统(SSO)的开发思路
单点登录并不是一个新鲜的玩意儿,比较官方的解释是企业业务整合的解决方案之一,通俗来讲SSO就是一个通用的用户中心,国内比较流行的UCenter就是一套单点登录解决方案.而近期以CSDN明文存储用户密码 ...
- Flash 导出图片和声音
命令文件 PolarBear_jsfl.zip Flash Professional 编辑器命令,用来导出 flash 库中的图片和声音 使用步骤: 1. 首先下载 PolarBear_jsfl.zi ...
- 简易博客编辑器:玩转document.execCommand命令
xhEditor是基于jQuery开发的跨平台轻量可视化XHTML编辑器,基于LGPL开源协议发布.今天就把它山寨一下. 上几张图,看看效果: 先做出菜单部分:发现是一张背景图片,所以用图片映射的方法 ...
- 内省与JavaBean
概述 JavaBean代表一类特殊的Java类,这种类主要用来存储和传递属性信息,JavaBean中的方法主要用于设置和获取这些私有属性,他们有一定的命名规则,我们可以把它们想象为一个侧重属性信息的类 ...
- 【转载】如何在C语言中调用shell命令
转载自:http://blog.csdn.net/chdhust/article/details/7951576 如何在C语言中调用shell命令 在linux操作系统中,很多shell命令使用起来非 ...
- Java Collections Framework
集合OR 容器 通常我们会用数组去保存一些基本数据类型,数组是编译器支持的类型,但是数组的一个明显缺点就是具有固定尺寸,而在一般情况下,只有在程序运行的时候,我们才能知道要保存的具体数目. Java类 ...
- 获取本机IP地址和MAC地址
unit NetFunc; interface uses SysUtils, Windows, dialogs, winsock, Classes, ComObj, WinInet, Variants ...
- [C++]VisualAssistX中文注释提示错误 解决办法
问题情况:Visual Assist X中文注释为提醒注释错误,而且在注释下面以红线标.问题原因:这是因为Visual Assist X认为中文的注释是拼写错误.问题处理: 1.打开 Microsof ...
- [Objective-c 基础 - 3.3] block数据类型
A.概念 1.block类似函数 (1)可以保存代码 (2)有返回值 (3)有形参 2.block的标志:^ // 没有参数和返回值的block void (^myblock)() = ^{ // ...