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

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #90 on: 2011-Feb-24 »
Matchy, your image is about XCode, but my problem is with GLBasic. I can not compile with GLBasic, so I can not get an XCode proyect and can not get errors there (errors that I will get! :D )
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 ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #91 on: 2011-Feb-24 »
Can someone please do a video of how to put the iADs in a GLBasic app?

If someone makes a video, I will be in the same problem, as I dont understand spoken english :D

Couldn't be easier to make a step-by-step guide?

(this is the guide I am making myself, it could be wrong and it is incomplete)

Quote
1.- Load your proyect
2.- inside your proyect dir, create a dir called iAD
3.- place inside this iad dir the files ADBannerView.h and ADBannerview.mm you will find in your xcode installation
4.- insert Matchy's code in your source (you have to place the comand INLINE at the beginning of this code, and ENDINLINE at the end)
5.- inter also the code
Code: (glbasic) [Select]
?IFDEF IPHONE
IMPORT "C" void glb_BannerInit()
?ELSE
FUNCTION glb_BannerInit:
DEBUG "[WIN] Banner Init (sim) \n"
ENDFUNCTION
?ENDIF
6.- call the function glb_BannerInit() somewhere in your program to display iADs
7.- in xcode (on the mac) .... NOT YET HERE.
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 ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #92 on: 2011-Feb-24 »
I'm very glad GLBasic itself seems so easy, that you are able to write such a cool game as the Krakout remake.

The problem is not about C being hard or easy (and GLB is an easy one!). The problem is that I have never read anything related to C, ever. On the Amiga I used to program in AMOS Pro and somethings in Assembler  :nana:
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 matchy

  • Prof. Inline
  • *****
  • Posts: 1544
    • View Profile
Re: iAd Banner - Technical only
« Reply #93 on: 2011-Feb-24 »
What about a music only video tutorial (not speaking) or would screen shot steps be better?  :|

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #94 on: 2011-Feb-24 »
I dont mind making myself the tutorial, as you see I am making a list/tutorial for myself with the steps I am making with the help of you all guys.

When I get the .mm files I could make advances. Or someone post them here or I will have to wait to be at home.
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 Moebius

  • Dr. Type
  • ****
  • Posts: 315
    • View Profile
Re: iAd Banner - Technical only
« Reply #95 on: 2011-Feb-24 »
The only thing you seem to be doing wrong:

At the end of your GLBasic file you have this as INLINE code:

Code: (glbasic) [Select]
// .h ////////////

// iAdBanner with GLB

#import "iAd/ADBannerView.h"

@interface AppViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView * bannerView;
UIView * _appView;
        UIWindow * _appWindow;
}

@property (nonatomic, retain) IBOutlet UIView * appView;
@property (nonatomic, retain) IBOutlet ADBannerView * bannerView;
@property (nonatomic, retain) IBOutlet UIWindow * appWindow;

- (void)createBannerView;
- (void)showBanner;
- (void)hideBanner;
- (void)changeBannerOrientation:(UIInterfaceOrientation)toOrientation;


@end



// .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 == UIInterfaceOrientationPortrait) | (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) | (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 {
if (UIInterfaceOrientationIsLandscape(toOrientation)) {
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierLandscape;
self.view.frame=CGRectMake(0,0, 320, 120);
} else {
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierPortrait;
self.view.frame=CGRectMake(0,0, 480, 100);
}
}

- (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;

self.view.frame = CGRectMake(0,0, 768, 66);
bannerView.frame=CGRectMake(0,-66, 768, 66);
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierPortrait;

[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=0;
[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];
}

GLBasic doesn't like this style of code as INLINE code, hence all the errors about the "@" and "-" symbols.
GLBasic's INLINE code is in "C++" not "Objective-C".
Instead, the simplest way I think is to use XCode for "Objective-C" code.  Don't worry I'll list steps in a second.

Unfortunately I can't make a video or even test this at the moment  :whistle: but from what I know this should work:

- Make a new file called something like "iAd.mm" - just make sure it ends in ".mm"
- Open the new file "iAd.mm" in a text editor (e.g. notepad)
- Copy the code I listed above from the end of your file into "iAd.mm" and save it.

- Delete the block of INLINE code from the end
- Delete this INLINE code from the end of your file.
- Leave the 'IMPORT' commands in your file.

- Compile your GLB project for XCode - it should work without any problems.

- Move "iAd.mm" into your XCode project folder with the other GLBasic files.

- Copy the XCode project onto your Mac, and open it in XCode.
- Click and drag "iAd.mm" into the 'Classes' folder in XCode, shown in Matchy's screenshot.

- Hit 'Build and Run' in XCode and see if it works!

I hope that you can understand that despite language problems, and I also hope it works...  then I won't need to bother testing  :good:
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #96 on: 2011-Feb-24 »
That's what I call an explanation!

Will test later at home...
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 matchy

  • Prof. Inline
  • *****
  • Posts: 1544
    • View Profile
Re: iAd Banner - Technical only
« Reply #97 on: 2011-Feb-24 »

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
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 msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: iAd Banner - Technical only
« Reply #99 on: 2011-Feb-24 »
¿Lo has probado ya, ampos?, ¿te ha funcionado?.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #100 on: 2011-Feb-24 »
Hasta esta noche no... ¡la siesta es sagrada!
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 msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: iAd Banner - Technical only
« Reply #101 on: 2011-Feb-24 »
Dí que sí hombre, el día que lo descubran éstos lo van a flipar.  :bed:

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #102 on: 2011-Feb-25 »
It works!!! Muahahahah!!!!

Now... how do I change iAd position?

I want the iAD to display at the bottom of the screen, not top.

I have changed the value

Code: (glbasic) [Select]
bannerFrame.origin.y=430;
and the iAD displays in the botton, but the finger-press does not work, neither in the displayed-bottom-iad or the previous-top position...
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 ampos

  • Prof. Inline
  • *****
  • Posts: 1599
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #103 on: 2011-Feb-25 »
Found!

Change only the value

Code: (glbasic) [Select]
self.view.frame = CGRectMake(0,430, 768, 66);
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 matchy

  • Prof. Inline
  • *****
  • Posts: 1544
    • View Profile
Re: iAd Banner - Technical only
« Reply #104 on: 2011-Feb-25 »
The bannerFrame.origin is where the banner will animate (move) to. Just set the area and where it should start.
Please check online documentation on the adbanner sizes. This is not tested and note the bannerHeight changes with orientation and iPad in this code:
Code: (glbasic) [Select]
self.view.frame = CGRectMake(0,480-50, 768, 50);  // create a space at the bottom of the screen for the adbanner for portrait iphone only
bannerView.frame=CGRectMake(0,480+50, 768, 50); // put it offscreen below the bottom so it will animate (move) upward on to the screen when initialized.
« Last Edit: 2011-Feb-25 by matchy »