Author Topic: iAd Banner - Technical only  (Read 45593 times)

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: iAd Banner - Technical only
« Reply #120 on: 2011-Mar-24 »
Hi matchy,
I´ve modified a bit the code and now the banner is beeing shown correctly (landscape bottom) but it seems I have lost the touch input in the rest of the screen.
The banner can be pressed but the ingame menus are not working anymore.

This is my modified code:

Code: (glbasic) [Select]
/*
 *  AppViewController.cpp
 */

#include "AppViewController.h"

// This filename is "AppViewController.mm"
#import "AppViewController.h"
@implementation AppViewController
@synthesize appView = _appView;
@synthesize bannerView; // = _bannerView;
@synthesize appWindow = _appWindow;
# pragma mark -
# pragma mark View

- (void)viewDidLoad {
[super viewDidLoad];
// NSLog(@"viewDidLoad");
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// NSLog(@"viewDidAppear");
}

//- (void)viewWillAppear:(BOOL)animated {
// NSLog(@"viewWillAppear");
// if (bannerView) {
// UIInterfaceOrientation orientation=self.interfaceOrientation;
// [self changeBannerOrientation:orientation];
// }
//}

- (void)dealloc {
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

#pragma mark -
#pragma mark ADBanner

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (bannerView) {
[self changeBannerOrientation:toInterfaceOrientation];
}
NSLog(@"shouldAutorotate");
}

- (void)changeBannerOrientation:(UIInterfaceOrientation)toOrientation {
//bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifier480x32;
//self.view.frame=CGRectMake(0,288, 480, 320);
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"bannerViewDidLoad");
// self.bannerView.hidden=NO;
[self showBanner];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
// self.bannerView.hidden=YES;
// NSLog(@"bannerView");
NSLog(@"E R R O R: '%@'",error);
// [self hideBanner];
}

- (void)createBannerView {
// NSLog(@"Banner creating...");
_appWindow = [[UIApplication sharedApplication] keyWindow];

bannerView=[[[ADBannerView alloc] init] autorelease];
bannerView.delegate=self;

bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifier480x32;
self.view.frame=CGRectMake(0,288, 480, 320);
bannerView.frame=CGRectMake(0,288, 480, 320);


[self.view addSubview:self.bannerView];
[_appWindow addSubview:self.view];
[_appWindow makeKeyWindow];



// [_appWindow makeKeyAndVisible];
}

- (void)showBanner {
// NSLog(@"Show banner");
CGRect bannerFrame=bannerView.frame;
bannerFrame.origin.y=288;
[UIView beginAnimations:@"showBanner" context:NULL];
bannerView.frame=bannerFrame;
[UIView commitAnimations];
}

- (void)hideBanner {
// NSLog(@"Hide banner");
CGRect bannerFrame=bannerView.frame;
bannerFrame.origin.y=-bannerFrame.size.height;
bannerView.frame=bannerFrame;
}

#pragma mark -
#pragma mark GLB

- (void)initBanner {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
[self performSelectorOnMainThread:@selector(createBannerView) withObject:nil waitUntilDone:YES];
[pool release];
}
@end

extern "C" void glb_BannerInit() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic createBannerView];
// [UIGlbasic release];
[UIGlbasic retain];
}

Are this values correct for bottom landscape?

   self.view.frame=CGRectMake(0,288, 480, 320);
   bannerView.frame=CGRectMake(0,288, 480, 320);

I can´t find where´s the problem...
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #121 on: 2011-Mar-25 »
I seem to get that in portrait mode when at the bottom of the screen. Everything works then once press the ad and it becomes full screen, closing it again will put the ad to the top of the screen plus not allow anything else on the screen to be touched...

Note this may be the latest iOS, as Matchy's free noisey soundboard also doesn't work once you select an ad. The ad fills the screen, you close it, everything looks good again (Matchy's app has it at the top of the screen so it looks exactly the same) except none of the screen buttons work anymore. Shaking to randomize seems to still work though.

Cheers
« Last Edit: 2011-Mar-25 by Crivens »
Current fave quote: Cause you like musicians and I like people with boobs.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #122 on: 2011-Mar-25 »
Hmm, haven't had much chance to look into this (not that I really know what I'm doing in XCode) but I found chucking in the self.view.frame=CGRectMake..etc. and bannerview.frame=CGRectMake..etc commands into the viewDidAppear section seemed to free it up from freezing after looking at an ad. Seems to work well if I change the Y coords to 0 if using a portrait ad that appears at the top of the screen, but can't seem to get it to work properly for the bottom of the screen. Repeating the exact same commands from the init routine works for showing it on the screen again, and control returns to the rest of the screen, but the ad itself seems to have moved it's "zone" if you see what I mean and touching it touches whats underneath). Strange...

I'm really just messing about though, so if anyone who knows what they are doing can take a look that would be great.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #123 on: 2011-Mar-25 »
I had it working properly at the bottom on my app...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #124 on: 2011-Mar-25 »
So did I with the changes Matchy posted. But then it seems once you click on an ad it locks it out for any other touches except the ad and puts the ad at the top. Making it at the top looks to fix it as it always appears there, but the lock out seems to happen even then. Very strange. Am sure it worked before too when you click on an ad. So it might be the latest iOS upgrade maybe. Anyway, even Matchy's free app that he pointed out works with iAds now doesn't work once you click on an Ad. I just tried it on a touch 4 and 3GS. Both freeze on Matchy's free app once an ad is clicked (ie. you can click another ad but not any other part of the screen). What I mentioned previously unlocks it after clicking on an ad but it only works 100% if the ad is at the top of the screen (it will redraw correctly at the bottom but not accept input again).

Unless of course you have further modified iAd code. If so then don't be shy! :)

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #125 on: 2011-Mar-25 »
I changed Matchy code to show iAD on the bottom, and it works fine. Just download my app and test on your device. Search in appstore as "diniplay" and download "magic coin box free".
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #126 on: 2011-Mar-25 »
Nope doesn't work anymore on mine (4.3 3GS). It's as I said in that it shows at the bottom then when you click on the ad, get full size, close the ad, then you see the ad go to the top of the screen and touching anywhere else on the screen does not respond. What I said earlier fixes the freezing but I cannot get it to work at the bottom of the screen properly. Top of the screen is perfect with what I said earlier so I think I am going to redesign my free version to be at the top of the screen. Annoying...

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #127 on: 2011-Mar-25 »
Strange, it works fine in my iphone 4 4.3...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #128 on: 2011-Mar-25 »
Are you clicking on the iAd to get the full screen ad appear? Then close it to return to your app? I just installed your free app on my touch 4 (retina) with iOS 4.3 and this causes the iAd to move to the top of the screen and then lock the screen on the main app area.

Im having dinner right now but I'll see if I can get a screenshot in a bit

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #129 on: 2011-Mar-25 »
Yes and yes.

Perhaps it is something with it showing TEST ADS for me instead of ads...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #130 on: 2011-Mar-25 »
Strange. Maybe it's because you are now compiling with XCode 4? I am using XCode 3 to compile my new free version (not upgrading until this is done) and the problem happens. Although I'm sure it didn't happen before (when Matchy first posted). Maybe the one on the store and Matchy's one were compiled on an older version and now don't work on 4.3? Out of interest can you purchase your own app? Do they charge you for it? Infact yours is free. Why not purchase it and see what happens?

I've attached some screenshots of your app from a 3GS. It shows before clicking on the ad, then the ad, then after the ad. At which point nothing works but clicking on the ad again. The same thing happens on my 4G iPod Touch (should be almost identical to iPhone 4).

Cheers

[attachment deleted by admin]
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #131 on: 2011-Mar-25 »
If you buy your own app you will be charged.

I am using XCode 3.2 still.

Matchy's iAD only works on 4.2.1+ . Ops, I just noticed my iPhone4 is still in 4.2.1.

On my brother iPhone4 4.2.1 it also shows test ads (perhaps same ip as we are on the same wifi?)

Strange.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #132 on: 2011-Mar-25 »
Must be 4.3 then. Oh well I will go with ads at the top then with my workaround to stop the freezing. At least until someone finds a better fix anyway.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: iAd Banner - Technical only
« Reply #133 on: 2011-Mar-25 »
any hint for landscape?

I cannot get any touch input in my menus, even if you dont press iad banner before.
iad banner itself works correctly.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: iAd Banner - Technical only
« Reply #134 on: 2011-Mar-26 »
I have tested further.

The problem with landscape view starts when I uncomment the shouldAutorotateToInterfaceOrientation function, but is necessary to do it in order to activate Landscape.
Once uncommented I lost all the app touch input.

If this is commented, as the code provided by matchy, all works fine but the view is locked to portrait. :(
I´m a bit lost.

Code: (glbasic) [Select]
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!