I think it would be better like this:
if (adBannerView != nil)
{
//Completely remove the bannerView
[adBannerView setDelegate:nil];
[adBannerView removeFromSuperview];
[adBannerView release];
adBannerView = nil;
}A fast, easy to use, free, and community supported 2D game engine
I think it would be better like this:
if (adBannerView != nil)
{
//Completely remove the bannerView
[adBannerView setDelegate:nil];
[adBannerView removeFromSuperview];
[adBannerView release];
adBannerView = nil;
}Thanks for the sample code... It was exactly what I needed to get started.
I noticed in the sample app that when tapping on the ads in landscape mode it doesn't work initially to tap on the word (center of the ad). You have to tap towards the left of the ad. After tapping on the left area it starts working regardless of where you tap. I don't see this issue in portrait mode.
In my app I updated the shouldAutorotateToInterfaceOrientation to return YES. It works initially to tap on the word but after tapping once it stops working to tap on the word (center of the ad) and it is necessary to tap towards the left on the ad. There are layout issues in the Sample after setting shouldAutorotateToInterfaceOrientation to returns YES.
Any ideas?
Has anyone tried using this sample code in xcode 4 on 4.3?
It works fine on 4.2 and below but for some reason on 4.3 the ad doesn't show up in the same position (I actually can't figure out where it goes) and a warning stating that the ad is obscured.
Is there a new way ads are supposed to be added in 4.3?
I tried this project out. It worked fine. When I put the code into my project i get an exception on:AdBannerView didMoveToWindow. Sadly im doing everything the same as far as I can tell as the sample project with a view contorller and the EAGLView. Anyone else hit this?
the only way i was ever able to get this to work was to create my ad during startup of app. Any time after that and this error would occur. Otherwise worked fine
You should check out my AdRootViewController on github: https://github.com/jandrad/AdRootViewController This one is updated and working fine!
Thats actually the sample app i started with :) Works great. I don't know why mine didnt work other then at startup. Something about being on the main thread although clearly not normally required.
I have problems with iAd, I can display the apple test add, but when I tap on the iAd the method:
-(BOOL)bannerViewActionShouldbegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
NSLog(@"bannerViewActionShould Begin called");
BOOL shouldExecuteAction = [self allowActionToRun];
if (!willLeave && shouldExecuteAction)
{
//I pause my game here when the iAd is tapped
NSLog(@"stopActionsForAd called");
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
return shouldExecuteAction;
}
never gets called, so my game is not paused and keeps running when the iAd is in full screen.
Has anybody had this problem? Any ideas on how to fix it?
Here is my code for iAd (my game runs in portrait mode only):
-(void)onEnter
{
NSLog(@"onEnter called");
[super onEnter];
adView = [[ADBannerView alloc]initWithFrame:CGRectZero];
adView.delegate = self;
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[[[CCDirector sharedDirector] openGLView] addSubview:adView];
adView.center = CGPointMake(adView.frame.size.width/2,40);
adView.hidden = YES;
}
-(void)onExit
{
adView.delegate = nil;
[adView removeFromSuperview];
[adView release];
adView = nil;
[super onExit];
}
- (BOOL)allowActionToRun
{
NSLog(@"allowActionToRun called");
return TRUE;
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd called");
adView.hidden = NO;
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"bannerView called - potentially with error %@",error);
adView.hidden = YES;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
NSLog(@"bannerViewActionDidFinish called");
// I resume game and music here, when paused
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation];
}
-(BOOL)bannerViewActionShouldbegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
NSLog(@"bannerViewActionShould Begin called");
BOOL shouldExecuteAction = [self allowActionToRun];
if (!willLeave && shouldExecuteAction)
{
//I pause my game here when the iAd is tapped
NSLog(@"stopActionsForAd called");
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
return shouldExecuteAction;
}Now working: I misspelled the name of the function "bannerViewActionShouldbegin" begin should be with capital "B"
So the correct name is "bannerViewActionShouldBegin"
Wow, took me almost 3 hours to find the problem :/ lol
Hi.. I tried this project.. works great on IOS 5.0.
But while running on simulator with IOS-4.0/4.1 It gives EXC_BAD_ACCESS at:
[adBannerView setRequiredContentSizeIdentifiers: [NSSet ..
Any idea?
@princegoyal1987 - perform a clean and build. You should get a warning about ADBannerContentSizeIdentifierPortrait <- that's not available until iOS4.2, you'll need to use the old identifiers (pre-iPad iAd's), the ones with the size (320x50) in them.
OR, of course just set the min iOS to 4.2 and not worry about it.
Thanks cybergreg, I made the changes to use AdMob for ios<4.2
You must log in to post.