views:

159

answers:

2

I'd like to generate some revenue for my OpenGL based iPhone app w/ Apple's iAds. Everything in the app is done w/ OpenGL including menus, buttons etc. How do I add iAds to my app?

More info: I've looked over sample code from Apple and I'm still stuck. Just fyi I currently don't use any view controllers. All I have is a "Window". I tried adding the bannerView to the window with the addSubView method but it just crashes the app. For some reason this works fine with the MailComposerView. Any help is appreciated!

More info: I created a subclass of UIViewController and put a BannerAd on it. Now the test advertisements show up. How do I make the rest of the UIView transparent such that the ads show up (with an alpha of 1.0) and I can also click on my buttons being created w/ OpenGL on the window below the UIViewController?

+4  A: 

Are you able to add UIViewControllers to the window?

If you can, create a UIViewController, which has an ADBannerView in it's UIView (done through Interface Builder), with the appropriate delegate methods connected.

Then add the UIViewController with a transparent background as a subview of the window.

Good luck!


Edit:

What code were you using to add the ADBannerView programmatically?


Regarding UITouch passthrough.

Two methods.

In the new UIViewController (set the UIView background to transparent using Interface Builder), you can override the UITouch hit test by throwing in this:

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
    // UIView will be "transparent" for touch events if we return NO
    return CGRectContainsPoint([adbanner frame], point));
}

Use the above method. It handles the banner sliding out of view, view rotations, etc. When you return NO (not in the bounds of the bannerview), it will believe that the point is not within this UIViewController, and will then ask the following layer.

The second, although easier method, has much room for error, so I will only describe it without posting code. Before you add the UIViewController's view, alter the UIView's frame such that it is only the size of the AdBannerView. This method does not account for rotation, banner sliding in/out. You need to handle these exceptions yourself, which makes this method more troublesome than it would seem.

Jus' Wondrin'
I tried [window addSubView:bannerView]; btw thanks for your response :-)
MrDatabase
+1  A: 

Hi,

This tutorial might help you.

iAd integration in iPhone.

You can also download the free 2010 WWDC videos from iTunes and check out Session 112 on integrating iAds into your app.

raaz