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 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作. 下 ...
随机推荐
- 静态Web开发 JQuery
伍章 JQuery 1节介绍JQuery和顶级对象 <<锋利的JQuery>>JQuery官网: http://jquery.com (下载jquery工具)JQuery在线A ...
- 优分享VR开源啦,优分享VR是基于Google VR开发的一款手机VR视频资源的聚合软件
欢迎来到优分享VR开源项目 优分享VR 开源中国Git地址: http://git.oschina.net/xumingwang/youkes_vr 优分享VR是 优分享安卓APP VR视频播放开源部 ...
- viedeo
http://download.farsight.com.cn/download/Android.htm
- 【暑假】[深入动态规划]UVa 12170 Easy Climb
UVa 12170 Easy Climb 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=24844 思路: 引别人一 ...
- uva 11991 Easy Problem from Rujia Liu? vector+map
水题 学习一下数据的存储方法. #include<iostream> #include<cstdio> #include<cstdlib> #include< ...
- 【转】开源C/C++网络库比较
在开源的C/C++网络库中, 常用的就那么几个, 在业界知名度最高的, 应该是ACE了, 不过是个重量级的大家伙, 轻量级的有libevent, libev, 还有 Boost的ASIO. ACE是一 ...
- 将COleDateTime类型数据转换成char *数据
用OpenCV做多摄像头校准时间,在图像上显示时间信息,需求要将COleDateTime类型数据转换成char *数据 具体代码如下: 1: COleDateTime m_checkDate; 2: ...
- leetcode@ [307] Range Sum Query - Mutable / 线段树模板
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...
- SGU132 - Another Chocolate Maniac(状态压缩DP)
题目大意 给定一个N*M大小的大小的蛋糕,蛋糕的有些地方已经放置了东西,要求你在蛋糕上放入尽量少的1*2大小的巧克力,使得蛋糕不能够再放入巧克力 题解 和POJ1038恰好相反,此题是放入尽量少的巧克 ...
- [读书笔记]了不起的node.js(四)
这周的学习主要是nodejs的数据库交互上,并使用jade模板一起做了一个用户验证的网站.主要是遇到了一下几个问题. 1.mongodb版本过低 npm ERR! Not compatible wit ...