Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / A step by step tutorial: How to add iAd to your games.(more details)

Author
Message
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Nov 2011 04:30
1. first of all, you should setup iAd in the iTunes Connect. Just need some clicks.It's very easy.

2. You should Create AdBannerView in viewDidLoad in the UntitledViewController.m

you should add this two lines to UntitledViewController.h. one is a variable in UntitledViewController.
follow is the code which should be added into viewDidLoad.

ADBannerContentSizeIdentifierPortrait is iAd orientation.You should change it if your game is in the other mode.
then , you should calculate the window size of iAd by Device. Then make a transform to AdBannerView.
when you create the AdBannerView, you should hide it. Because maybe the iAd request will fail. The Apple Inc. don't want to see a white window in your games.

3.You should add delegate to UntitledViewController as follow code.


then, add two variables in UntitledViewController


then you should add some functions about AdBannerView.

Pay attention to these two functions:
one, didFailToReceiveAdWithError, you should hide the AdBannerView, if there is a error about it.
two,bannerViewDidLoadAd, it means the ads is ready, you can show or hide it by your game state.

4. add your function to UntitledViewController : - (void) showAdvBOOL)bShow;

You can call this function in your cpp file. Then you can control the ads show or hide.
That's all. It's very easy, right?

Any questions can follow this thread. I'll answer as quickly as I can.

Halley

The Miracrea Games

Login to post a reply

Server time is: 2024-04-18 15:00:01
Your offset time is: 2024-04-18 15:00:01