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 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作. 下 ...
随机推荐
- 理解Android的手势识别
对于触摸屏,其原生的消息无非按下.抬起.移动这几种,我们只需要简单重载onTouch或者设置触摸侦听器setOnTouchListener即可进行处理.不过,为了提高我们的APP的用户体验,有时候我们 ...
- 【管理工具】Kerberos简单应用
Kerberos这一名词来源于希腊神话“三个头的狗——地狱之门守护者”系统设计上采用客户端/服务器结构与DES加密技术,并且能够进行相互认证,即客户端和服务器端均可对对方进行身份认证.可以用于防止窃听 ...
- FZU2150 Fire Game BFS搜索
题意:就是选两个点出发,只能走草坪,看能不能走完所有的草坪 分析:由于数据范围很小,所有枚举这两个点,事先将所有的草坪点存起来,然后任选两个点走,(两个点可以是同一个点) 然后BFS就行了 注:无解的 ...
- java快速获取大图片的分辨率(大图片格式JPG,tiff ,eg)
问题描述:怎样快速获取一个20MB图片的分辨率? 程序代码: package test; import java.awt.Dimension; import java.awt.image.Buffer ...
- opencv linux
This link which you also mentioned describes the necessary steps to compile OpenCV on your machine. ...
- Java String StringBuffer StringBuilder
String 字符串常量存储在常量区,每次追加操作会创建新的对象: StringBuffer 字符串变量 线程安全 在堆上创建,每次追加操作在原对象上进行操作: 速度 StringBuffer ...
- 3.1 全局存储带宽与合并访问 -- Global Memory(DRAM) bandwidth and memory coalesce
全局存储带宽(DRAM) 全局内存是动态随机访问的方式访问内存.我们希望访问DRAM的时候非常快,实际情况是DRAM中出来的数据非常非常慢,这就好比,理想状态是泄洪,水倾巢而出,气势宏伟,实际取水却像 ...
- Docker系列(七)Shipyard安装及介绍
Shipyard 是一个基于 Web 的 Docker 管理工具,支持多 host,可以把多个 Docker host 上的 containers 统一管理:可以查看 images,甚至 build ...
- HW6.30
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- [Objective-c 基础 - 2.8] category分类/类别/类目
A.给某个类扩充方法(不改变原来的类) 例如,给类Person加上名为Simon的category,加上一个-study方法 使用()注明 Person+Simon.h @interface Pers ...