iAd
by Pedro Vicente · in iTorque 2D · 06/15/2011 (1:11 pm) · 5 replies
Hello everyone
I was wondering if anyone got iAd integrated with iTorque2D
developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iAd_Gui...
I was wondering if anyone got iAd integrated with iTorque2D
developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iAd_Gui...
#2
Are there any plans to support iAds in the near future?
The problem here seems to be that iTorque2D does not have a UIViewController (and ADBannerView requires a view controller); so one must be defined and integrated with CAEAGLLayer, that is used to render iTorque; one solution might be to have a dedicated area for iAds only
developer.apple.com/library/ios/#DOCUMENTATION/QuartzCore/Reference/CAEAGLLayer_...
06/20/2011 (1:44 pm)
@GG staffAre there any plans to support iAds in the near future?
The problem here seems to be that iTorque2D does not have a UIViewController (and ADBannerView requires a view controller); so one must be defined and integrated with CAEAGLLayer, that is used to render iTorque; one solution might be to have a dedicated area for iAds only
developer.apple.com/library/ios/#DOCUMENTATION/QuartzCore/Reference/CAEAGLLayer_...
#3
Its not like the context rotates physically so even hooking it in there wouldn't do much.
Instead you would better and also easier to use a view controller which covers only the interactable banner area and overlay that one by pushing it in front
06/20/2011 (10:27 pm)
and why would you need to integrated it with the CAEAGLLayer?Its not like the context rotates physically so even hooking it in there wouldn't do much.
Instead you would better and also easier to use a view controller which covers only the interactable banner area and overlay that one by pushing it in front
#4
I meant using a view controller that manages both CAEAGLLayer and the ADBannerView, making these 2 views "siblings", not ADBannerView integrated with CAEAGLLayer.
Yes, I actually tried that...That is what I do in this modified code version. But the problem is still there, I loose all the CAEAGLLayer input after the ADBannerView shows an ad; therefore the suggestion of the view controller managing both views.
06/21/2011 (12:56 am)
@MarkQuote:and why would you need to integrated it with the CAEAGLLayer?
I meant using a view controller that manages both CAEAGLLayer and the ADBannerView, making these 2 views "siblings", not ADBannerView integrated with CAEAGLLayer.
Quote:Instead you would better and also easier to use a view controller which covers only the interactable banner area and overlay that one by pushing it in front
Yes, I actually tried that...That is what I do in this modified code version. But the problem is still there, I loose all the CAEAGLLayer input after the ADBannerView shows an ad; therefore the suggestion of the view controller managing both views.
- (void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectMake(0.0f, 0.0f, 320.0, 50.0);
self.view.frame = CGRectMake(0.0f, 0.0f, 320.0, 50.0);
adView.hidden = YES;
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.delegate = self;
[self.view addSubview:adView];
self.bannerIsVisible = NO;
[super viewDidLoad];
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
adView.hidden = NO;
[self.view bringSubviewToFront:adView];
}
#5
iAd
The problem here was that the ad view was being added as a subview of the default view
one way to fix this (probably there are others) was to make the default controller view the ADBannerView instance
09/27/2011 (6:55 pm)
I fixed this and posted a resource hereiAd
The problem here was that the ad view was being added as a subview of the default view
[self.view addSubview:adView];
one way to fix this (probably there are others) was to make the default controller view the ADBannerView instance
self.view = adView;
Torque 3D Owner Pedro Vicente
Space Research Software LLC
developer.apple.com/videos/wwdc/2010/
Based on it I defined a ADBannerView instance. Problem is that the Torque game becomes irresponsive and clicking in the ad banner changes my app's orientation :-)
Code is
In TGBAppDelegate.mm, I added this to the end of this function
- (void)applicationDidFinishLaunching:(UIApplication *)application { ... ViewController *View = [[ViewController alloc] init]; [window addSubview: View.view]; }The ViewController class is
ViewController.h
#import <UIKit/UIKit.h> #import "iAd/ADBannerView.h" @interface ViewController : UIViewController <ADBannerViewDelegate> { ADBannerView *adView; }ViewController.mm
This defines a ADBannerView instance that is well behaved: it is shown initially hidden and then shown visible when there is an ad in the iAd network to show; it hides the banner again if the iAd network returns no ads to show (like a case of no network connection).
#import "ViewController.h" @implementation ViewController - (void)viewDidLoad { adView = [[ADBannerView alloc] initWithFrame:CGRectZero]; adView.hidden = YES; adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierLandscape]; adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape; adView.delegate = self; [self.view addSubview:adView]; [super viewDidLoad]; } -(void)viewDidUnload { adView.delegate = nil; adView = nil; } -(void)dealloc { adView.delegate = nil; [adView release]; adView = nil; [super dealloc]; } #pragma mark ADBannerViewDelegate methods -(void)bannerViewDidLoadAd:(ADBannerView *)banner { adView.hidden = NO; } -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { adView.hidden = YES; } @endInitial view
After clicking the banner
After closing the ad