Here is a video and source test for Apple's iAd Banner with GLB. :good:
http://www.youtube.com/watch?v=ndQYcpnGTGQ
Easy to implement and works for portrait and landscape rotatable, so room for these function parameters. The only small objc issue is if I set the banner at the bottom of the screen, it jumps back to the top after viewing the ad. :sick:
Update: my file removed...used trucidare's!
[UPDATE]
Latest version seems here:
http://www.glbasic.com/forum/index.php?topic=5932.new;topicseen#new (http://www.glbasic.com/forum/index.php?topic=5932.new;topicseen#new)
Wow, amazing!
I was going to have to figure this out on my own!
I took a look at your code, it seems easy to implement.
But, I'm not quite sure how to use it.
Do I call 'GLB_iAd_Init()' just before I want to display an iAd?
For example, call it on a loading screen.
But then how do I clear it when the level is ready?
I noticed the 'GLB_iAd_Init()' call is outside of your SHOWSCREEN loop.
And, does it automatically revert to an actual iAd (not a 'testing' ad) when deployed to iTunes?
Thanks,
Slydog, please have a go at implementing it as it is very easy. It's seems that when iAd Banner is initialized it stays there and can't be removed. It's early days, so I don't know much about it. I'm hoping we can work this one out!
Thanks.
I was researching it a bit, and it does get complicated, for something that seems so easy.
I found this page on apple.com:
http://developer.apple.com/iPhone/library/documentation/UserExperience/Conceptual/iAd_Guide/WorkingwithBannerViews/WorkingwithBannerViews.html#//apple_ref/doc/uid/TP40009881-CH4-DontLinkElementID_21 (http://developer.apple.com/iPhone/library/documentation/UserExperience/Conceptual/iAd_Guide/WorkingwithBannerViews/WorkingwithBannerViews.html#//apple_ref/doc/uid/TP40009881-CH4-DontLinkElementID_21)
It gets into how to handle ads that don't return anything, and how to handle a banner touch.
In the error handling, it has a line:
self.bannerIsVisible = NO;
So this is maybe how we hide it when not needed anymore.
It mentions 'self', which I assume is referring to the iAd instance?
But, since I've never even loaded XCode yet, or touched Objective C, I've got a lot of learning ahead!
Have iAd working with touch after closing the ad.
Does it work at the bottom, too?
it work whereever you want.
have to add position markers for that.
at the moment i placed it on top and it is shown after an ad is loaded, so no empty iad frame is visible.
Excellent. I might try to use it in the bottom of the ScribbleMP/Settings dialog.
glad to ear about this.
Will be great for lite apps!
How is going?
The issue I found that I was unable to get the GLB screen mouse response after closing the iAd. :'(
matchy this is fixed now ;)
So, as far as I undestand, is totally usable now?
it is
oops i´m old :( forgot to release the corrected lib from matchy.
i will later this day
Sounds good trucidare. :) I can't get mousestate. :'( How did you fix it?
i got kungphoos glbasic view and changed the singleton to my own objC class.
EDIT:// download in this post
[attachment deleted by admin]
Quote from: matchy on 2010-Jul-21
Sounds good trucidare. :) I can't get mousestate. :'( How did you fix it?
// --------------------------------- //
// Project: iAdTest
// Start: Friday, June 25, 2010
// IDE Version: 8.002
REQUIRE "import.c"
IMPORT "C" int GLB_iAd_Init()
Animate()
FUNCTION Animate:
LOCAL mx,mx,b1,b2
GLB_iAd_Init()
WHILE TRUE
MOUSESTATE mx,my,b1,b2
DRAWRECT 0,50,320,100,RGB(0,255,0)
PRINT "GLB: Hello iAd world!",10,60+SIN(GETTIMERALL()*0.1)*10
DRAWRECT mx-10,mx-10,20,20,RGB(255,0,0)
SHOWSCREEN
WEND
ENDFUNCTION
This code here is slightly different from the one available for download. I think it has an additional mousestate command. Which one is the final one?
Oh, and I dont know where to find those iad and CoreGraphics Frameworks.
Quote from: trucidare on 2010-Jul-21
i got kungphoos glbasic view and changed the singleton to my own objC class.
EDIT:// download in this post
Does this wrapper replace matchy's glb_iad solution?
it is a standalone lib. read Readme.txt for function names.
it is matchys idea with my patch for get input working
Quote from: trucidare on 2010-Jul-21
it is a standalone lib. read Readme.txt for function names.
it is matchys idea with my patch for get input working
Could you walk me through adding it? The readme shows three functions, GLB_iad, GLB_iad_hide and GLB_iad_show. I added them to my game. Do i need to include that libiad.a file too? And how do i do that if it's needed? Are these functions related to the GLB_iad_init one from matchy's solution? And they are void instead of int like GLB_iad_init.
baicskillet, add the existing framework and lib in xcode!
trucidare, I tried out the lib and the result was I there was mousestate feedback and the banner frame slides nicely.
Although there is no advert text or image in the banner test frame (server issue), there now is no response when tapping the advert.
//iAd Banner Lib Test
//undelcared variables are psuedo
IMPORT "C" void GLB_iAd()
IMPORT "C" void GLB_iAd_Hide() // to hide the banner
IMPORT "C" void GLB_iAd_Show() // to show banner after hide
GLB_iAd()
WHILE TRUE
if time_to_show
GLB_iAd_Show()
elseif time_to_hide
GLB_iAd_Hide()
endif
PRINT banner_state,0,0
SHOWSCREEN
WEND
thats why i hide it automaticaly. it will be shown if the ad was loaded. then its clickable.
I don't see any test ad images at the moment, just he frame with iAd logo. Should I be seeing the test ad as it does seem to load it?
you need to have wifi on
I am on WiFi! Are you getting test ads?
not tested last days, but before i got the Apple Test Add and on click i got the Voila it works thing ;)
if the iAd frame is shown, iAd works fine, but not receiving the Ad from apple i think.
Yeah I'll try it some other time again as the frame is working fine. :booze:
perfect :D
Quote from: matchy on 2010-Jul-22
baicskillet, add the existing framework and lib in xcode!
trucidare, I tried out the lib and the result was I there was mousestate feedback and the banner frame slides nicely.
Although there is no advert text or image in the banner test frame (server issue), there now is no response when tapping the advert.
//iAd Banner Lib Test
//undelcared variables are psuedo
IMPORT "C" void GLB_iAd()
IMPORT "C" void GLB_iAd_Hide() // to hide the banner
IMPORT "C" void GLB_iAd_Show() // to show banner after hide
GLB_iAd()
WHILE TRUE
if time_to_show
GLB_iAd_Show()
elseif time_to_hide
GLB_iAd_Hide()
endif
PRINT banner_state,0,0
SHOWSCREEN
WEND
Yeah, I figured that out on xcode. I added that iad .a file to the lib folder in glbasic too. Is that routine in your post for displaying and hiding the ads? It only has GLB_iAd_Hide, GLB_iAd_Show and GLB_iAd. There's no GLB_iAd_Init.
Ok, I figured, glb_iad_init only makes the rectangle where the banners are supposed to be. And glb_iad_init, glb_iad_hide and glb_iad_show are for actually putting the banners. Did i get it right?
It compiles for me, but it gives warnings about possible unassigned variables, time_to_show, time_to_hide, and banner_state.
Those import function are for trucidare's lib.
How about landscape banner?
Quote from: matchy on 2010-Jul-22
Those import function are for trucidare's lib.
How about landscape banner?
Ok, got it. But, did I get it right with my previous post? I'm a noob, i know.
GLB_iAd is the Init function. Call it on start of zour GLBasic tool.
I am adding this to a iPhone game.
I placed the libiad.a file in xcode/glbasic/libs/
Then, in the XCode project I drag the file into the "Frameworks" line on the left of xcode window.
I added the following to the GLB source:
IMPORT "C" void GLB_iAd()
IMPORT "C" void GLB_iAd_Hide() // to hide the banner
IMPORT "C" void GLB_iAd_Show() // to show banner after hide
I can compile as Win with no errors.
My source:
IMPORT "C" void GLB_iAd()
IMPORT "C" void GLB_iAd_Hide() // to hide the banner
IMPORT "C" void GLB_iAd_Show() // to show banner after hide
LOADBMP "start.png"
GLB_iAD()
SHOWSCREEN;REPEAT;UNTIL MOUSEAXIS(3)=1
...//rest of source
As soon as I add the line GLB_iAD(), GLB does not compile woth the folowing error:
Quote
linking:
gpc_temp0.o:gpc_temp0.cpp:(.text+0xdc2c): undefined reference to `_GLB_iAd'
*** FATAL ERROR - Please post this output in the forum
But I can compile as target->iPhone with no errors ON GLB.
Once in Mac with xCode, If I try to build&run, I get a ton of errors:
QuoteBuild iPhone of project iPhone with configuration Debug
Check dependencies
[WARN]Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'iPhone-Info.plist'.
Ld build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv6/iPhone normal armv6
cd /Volumes/Proyectos/MagicBox/XCode/GLBasic
setenv IPHONEOS_DEPLOYMENT_TARGET 3.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Volumes/Proyectos/MagicBox/XCode/GLBasic/build/Debug-iphoneos -L/Volumes/Proyectos/MagicBox/XCode/GLBasic/Lib -F/Volumes/Proyectos/MagicBox/XCode/GLBasic/build/Debug-iphoneos -filelist /Volumes/Proyectos/MagicBox/XCode/GLBasic/build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv6/iPhone.LinkFileList -dead_strip -lstdc++ -miphoneos-version-min=3.0 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework AudioToolbox -framework CoreLocation -framework OpenAL -lGLBasiciPhone-egl -lpng-gf -lPROGRAM -framework MediaPlayer -liAd -o /Volumes/Proyectos/MagicBox/XCode/GLBasic/build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv6/iPhone
Undefined symbols:
"_CGRectOffset", referenced from:
-[Exports _GLB_iAd_Show] in libiAd.a(Exports.o)
-[Exports _GLB_iAd_Hide] in libiAd.a(Exports.o)
"_ADBannerContentSizeIdentifier320x50", referenced from:
_ADBannerContentSizeIdentifier320x50$non_lazy_ptr in libiAd.a(Exports.o)
(maybe you meant: _ADBannerContentSizeIdentifier320x50$non_lazy_ptr)
"_ADBannerContentSizeIdentifier480x32", referenced from:
_ADBannerContentSizeIdentifier480x32$non_lazy_ptr in libiAd.a(Exports.o)
(maybe you meant: _ADBannerContentSizeIdentifier480x32$non_lazy_ptr)
"_OBJC_CLASS_$_ADBannerView", referenced from:
_OBJC_CLASS_$_Exports in libiAd.a(Exports.o)
objc-class-ref-to-ADBannerView in libiAd.a(Exports.o)
"_OBJC_METACLASS_$_ADBannerView", referenced from:
_OBJC_METACLASS_$_Exports in libiAd.a(Exports.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
Ld build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv7/iPhone normal armv7
cd /Volumes/Proyectos/MagicBox/XCode/GLBasic
setenv IPHONEOS_DEPLOYMENT_TARGET 3.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Volumes/Proyectos/MagicBox/XCode/GLBasic/build/Debug-iphoneos -L/Volumes/Proyectos/MagicBox/XCode/GLBasic/Lib -F/Volumes/Proyectos/MagicBox/XCode/GLBasic/build/Debug-iphoneos -filelist /Volumes/Proyectos/MagicBox/XCode/GLBasic/build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv7/iPhone.LinkFileList -dead_strip -lstdc++ -miphoneos-version-min=3.0 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework AudioToolbox -framework CoreLocation -framework OpenAL -lGLBasiciPhone-egl -lpng-gf -lPROGRAM -framework MediaPlayer -liAd -o /Volumes/Proyectos/MagicBox/XCode/GLBasic/build/iPhone.build/Debug-iphoneos/iPhone.build/Objects-normal/armv7/iPhone
Undefined symbols:
"_CGRectOffset", referenced from:
-[Exports _GLB_iAd_Show] in libiAd.a(Exports.o)
-[Exports _GLB_iAd_Hide] in libiAd.a(Exports.o)
"_ADBannerContentSizeIdentifier320x50", referenced from:
_ADBannerContentSizeIdentifier320x50$non_lazy_ptr in libiAd.a(Exports.o)
(maybe you meant: _ADBannerContentSizeIdentifier320x50$non_lazy_ptr)
"_ADBannerContentSizeIdentifier480x32", referenced from:
_ADBannerContentSizeIdentifier480x32$non_lazy_ptr in libiAd.a(Exports.o)
(maybe you meant: _ADBannerContentSizeIdentifier480x32$non_lazy_ptr)
"_OBJC_CLASS_$_ADBannerView", referenced from:
_OBJC_CLASS_$_Exports in libiAd.a(Exports.o)
objc-class-ref-to-ADBannerView in libiAd.a(Exports.o)
"_OBJC_METACLASS_$_ADBannerView", referenced from:
_OBJC_METACLASS_$_Exports in libiAd.a(Exports.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
PLEASE, can someone help me, or make a
iAD Guide for TotalNoobs?
You'll need to add the CoreGraphics and iAd framework. That's what those errors are causing.
What/where is this core thing?
Are you serious? What's wrong with researching it? >:D
I have been searching, and found nothing. Where do I find this CoreGraphics thing?
Right click on Frameworks folder. :noggin:
Quote from: matchy on 2010-Nov-20
Right click on Frameworks folder. :noggin:
->right click on Framework folder -> Add -> Existing Framework
And when you search for it on the net, there are 1000s of references. :whistle:
I have also added the existing framework "iad.framework" to frameworks folder (when I got it running, will post here a "dumb-guide").
Ok, now xcode compiles, but after running, I got this error in xcode debugger:
Quote
mi_cmd_stack_list_frames: Not enough frames in stack.
(PS: how do I setup the ad on the botton of the screen?)
Maybe it's just the view controller frame co-ords but not as I have to find out for myself soon. :S
And the xcode debuuger error? The app does not launch...
Quote from: ampos on 2010-Nov-20
"dumb-guide"
Who? O_O
Check your versions:
http://www.google.com/search?source=ig&hl=en&rlz=&=&q=mi_cmd_stack_list_frames%3A+Not+enough+frames+in+stack&btnG=Google+Search&aq=&oq=
In this case, Sanit Google seems not to be alot of helpfull... will test a ton of the things google says can be...
LOL
I have tried once more and... it runs with no error. No idea, as I have not done anything...
...but it doesnt work. It doesnt show anything.
I call GLB_IAD() at the start of my program, and glb_iad_show() before the main loop or inside the main loop (before showscreen) and nothing is shown. Not even a black frame...
Keep trying. It's how I learn and get it done.
I dont know what else to try. No errors and no ad.
Can you do a little test program that works?
There's no point in a tutorial when there are no GLB with iAd apps on the market. If an app was submitted with the current wrapper, it will be rejected.
In the meantime, I've been able to get iAd to work with GLB but with issues to address which I'm still working on. That is; "Responding to a Touch in the Banner View" (pausing) and "Changing the Banner Size Dynamically" (orientation).
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iAd_Guide/WorkingwithBannerViews/WorkingwithBannerViews.html
I have an App that could go with iAD. As soon as you get something that works, I will upload it to AppStore...
Quote from: ampos on 2010-Dec-15
I have an App that could go with iAD. As soon as you get something that works, I will upload it to AppStore...
Wow...you have an app that could go with iAd? That's great. I'll work extra hard tonight so that I get it done for you. :)
That would be nice!
I have a app, too! :nw:
I want it on the config screen of ScribbleMP, too.
Lol. Was there only me who got matchy's sarcasm:). Or....were you all a step ahead and being sarcastic too
Can't fault you match ;)
Oh, matchy didn't mean it? Aw :/ I fell for it.
matchy, pleaaaaaaaaase! :D
I would buy you a drink, if you are fast enough :)
Fellas......take it easy please! I'm going to try and update trucidare wrapper later. :zzz:
[sarcasm.touché]
Now continue your delightful chat about me and never mind topics about iAd policies!
[/sarcasm.touché]
:D =D
Did an App store approvable version ever get made for iAds? This and in-app purchases are probably my greatest interest in GLB improvement as an iPhone development language.
Cheers
No. Why don't you try it?
Sorry Matchy, but he can not try because it does not work.
Oh. The only current issue I have is that the banner needs to tell glb that it's being pressed and I'm not sure how to do that from the iAd delegate (or any other running objc in the background).
Just to note, xcode 4.3 beta now has full-screen iAds also.
Sorry, I have deleted off topic post
This had just been accepted with GLB and iAd!!! It's free so please download it and tell me if the adverts are display okay!
http://www.glbasic.com/forum/index.php?topic=3857.msg44202#msg44202
Nice job matchy, but unfortunately just after the loading animation seems to complete the app crashes :doubt:
I'm using an iPod Touch 2G in Australia.
It loads and appears to work fine at first - I got the main "game" and an ad for LYNX deo at the top, stating "Tap Here" which when tapped took me to the LYNX EXCITE site. X'ing brought me back to the app. All good so far.
However, when I went back to app (now with a different ad at the top) there was no sound and the "buttons" went into spasm - the wavy lines kept playing in each "button" I'd pressed before going to the ad site. Pressing a new button caused more wavy lines, but no sound. Exiting the app with HOME and restarting made no difference - the app stayed the same. Turning off and back on again was the same.
I tried shaking it and eventually the buttons cleared, but then only the top three buttons went wavy, but still with no sound. The buttons responded to my touch (the colour changed and the highlight moved), but they didn't produce any waves (or sound).
I've turned off, shaken, exited and pressed everthting multiple times, but still no joy. Oh and the ads aren't appearing now either.
So it's a partial success... At least it didn't crash.
BTW iPod Touch 2G (Sept 2010) 32GB.
Oh...thanks so much for testing, dudes. At least the adverts are showing because they don't show for me for some reason, even on non-GLB apps...only test ads. There's no (required) code to detect that the advert was selected.
Anyhow, I'll have to review my code regarding missing sound and lines, but I think this is not a iAd issue as I experience missing "waves" on WinCE also so I removed them.
Just to note, the sound app creates wav files user folder, loads them into memory, then deletes them.
Hi Matchy -
My finger is tired :D
I tested on an iphone 4 (8 GB) w/ ios 4.1. No problems, no crashes - everything seems to work fine. I haven't see an iad yet, though - I'm in the U.S. (not sure if that has any relevance). I've read that iads are in short supply due to a significant downturn in sales after Christmas, so it may take a while to see them. I'll let you know if I do.
The only time I don't receive test adverts with an error that they are not available, is when the device date and time are incorrect. Sometimes it can be confusing but it's safe to know that they are displaying.
Here's the source which works for iPhone and iPad. This version is set for top portrait with orientation omitted.
There are two files "AppViewController.h" and "AppViewController.mm" that need to be created in a new folder "Classes".
Steps 1 - 21
1. Log on to windows and open GLB and create an new project called "AdBannerTest".
2. Paste the following GLB code:
glb_BannerInit()
WHILE TRUE
DRAWRECT 0,0,320,480
SHOWSCREEN
WEND
?IFDEF IPHONE
IMPORT "C" void glb_BannerInit()
?ELSE
FUNCTION glb_BannerInit:
DEBUG "[WIN] Banner Init (sim) \n"
ENDFUNCTION
?ENDIF
3. Save the project
4. Run the AdBannerTest program.
4. Build for iPhone.
5. Close GLB.
6. Open the "AdBannerTest\Xcode\" folder with Windows Explorer.
7. Two files for Xcode need preparing. Create a folder named "Classes"
8. Create two new text files and rename them to "AppViewController.h" and "AppViewController.mm"
9. Open the blank file "AppViewController.h" and paste the following ObjC code:
// This filename is "AppViewController.h"
#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
10. Save the file "AppViewController.h" and close it.
11. Open the file "AppViewController.mm" and paste the following code:
// 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 == 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];
}
13. Save the "AppViewController.mm" file and close it.
14. If there is no Mac on the LAN, copy the "AdBannerTest\XCode\" folder to a USB drive.
14. Log out of Windows.
15. Log in to Mac.
16. Open the "AdBannerTest\XCode\" folder with Mac Finder.
17. Open the Xcode project.
18. Open the "AdBannerTest\XCode\Classes" folder with Mac Finder.
19. Drag the files "AppViewController.h" and "AppViewController.mm" to the Class folder in Xcode.
20. Add the iAd Framework.
21. Compile for iPhone.
Can someone explain to a full-idiot how to use this?
BTW, your app shows me "test ads"
Add the class to the xcode resources, iAd framework and call this from GLB:
IMPORT "C" void glb_BannerInit()
When an app goes live on the App Store, it should be showing real ads. It is strange that you are getting tests ads (I presume it says "Test Advertisement") which are only available before the app is approved.
Ampos, please note: I don't appreciate your attitude be degrading yourself and there's no need for sly remarks.
When I said "full-idiot" I was meaning a guide to total noobs, as really this c things overpasses me, and also I am not english speaker and we can get some lñanguage barriers too (or at least, the way we voiced our ideas).
Continuing with the post theme, let me clarify if I get this...
In my glb program I should insert at the end this:
INLINE
...your c code
ENDINLINE
and in the xcode proyect, in resources, add "iad framework"...
Then just at anypoint of the program
?IFDEF IPHONE
glb_BannerInit()
?ENDIF
ALso I remember there was glb_show() and glb_hide() and perhaps others. Are they still there, or aren't they needed anymore?
About the test app, maybe I am wrong as I can not find again the doc were how iad works was explained in apple website, but I remember there was an explanation that you should change something once the app was released...
ad_animate()
FUNCTION ad_animate:
glb_BannerInit()
WHILE TRUE
PRINT "AdBanner Test", 10, 100
SHOWSCREEN
WEND
ENDFUNCTION
?IFDEF IPHONE
IMPORT "C" void glb_BannerInit()
?ELSE
FUNCTION glb_BannerInit:
DEBUG "[WIN] Banner Init (sim) \n"
ENDFUNCTION
?ENDIF
I get this error:
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:2991:29: iAd/ADBannerView.h: No such file or directory
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:2995: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:2995: error: `interface' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3007: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3007: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3009: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3009: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3011: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3011: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3015: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3017: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3019: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3021: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3027: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3039:30: AppViewController.h: No such file or directory
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3043: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3027: error: `end' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3047: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3049: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3049: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3051: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3051: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3063: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3073: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3099: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3141: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3161: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3163: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3173: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3179: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3189: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3225: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3233: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3243: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3265: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3269: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3277: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3283: error: expected constructor, destructor, or type conversion before "extern"
*** FATAL ERROR - Please post this output in the forum
I have created a dir called "iad" and inside placed the files "addbanner.h" & "iad.h" found in the mac, and now got this error:
compiling:
In file included from C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3013:
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:8:24: UIKit/UIKit.h: No such file or directory
In file included from C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3013:
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:20: error: `NSUInteger' does not name a type
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:22: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:22: error: `protocol' does not name a type
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:34: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:34: error: `interface' does not name a type
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:38: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:41: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:41: error: expected constructor, destructor, or type conversion before '(' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:48: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:48: error: expected constructor, destructor, or type conversion before '(' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:54: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:54: error: expected constructor, destructor, or type conversion before '(' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:58: error: expected unqualified-id before '+' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:61: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:61: error: expected constructor, destructor, or type conversion before '(' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:65: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:65: error: expected constructor, destructor, or type conversion before '(' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:69: error: expected unqualified-id before '-' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:71: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:73: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:71: error: `end' does not name a type
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:74: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:83: error: expected unqualified-id before '-' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:92: error: expected unqualified-id before '-' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:97: error: expected unqualified-id before '-' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:99: error: stray '@' in program
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:101: error: expected constructor, destructor, or type conversion before "extern"
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:105: error: expected initializer before '*' token
D:/Programas/GLBasic/Proyectos/MagicBox/iAd/ADBannerView.h:106: error: expected initializer before '*' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3017: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3017: error: `interface' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3029: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3029: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3031: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3031: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3033: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3033: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3037: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3039: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3041: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3043: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3049: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3061:30: AppViewController.h: No such file or directory
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3065: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3049: error: `end' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3069: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3071: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3071: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3073: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3073: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3085: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3095: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3121: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3163: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3183: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3185: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3195: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3201: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3211: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3247: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3255: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3265: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3287: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3291: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3299: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:3305: error: expected constructor, destructor, or type conversion before "extern"
*** FATAL ERROR - Please post this output in the forum
You want fish or learn how to fish?
Try it without glb!
http://www.youtube.com/results?search_query=xcode+iad+tutorial&aq=f
er.... I want a fish. =D
How can I compile for iPhone, if GLBasic gives me an error when trying to compile for iphone?
Ig GLB does not generate the xcode proyect, I will not be able to compile in Mac-xcode for iphone...
Also, I can understand spoken english barely, so a youtube video is not an option for me.
I love you trying to teach me how to, but really, it exceeds me.
Coould you try a step-by-step how-to?
1. Drag AdViewController.h and AdViewController.mm to the Class folder of the glb xcode project. Note my source as contains both the header (.h) and class (.mm). I presume your errors show that you may have not done this.
2. Add the iAd framework.
If that doesn't work then I'll have to make a video.
Perhaps I dont understand you, but the problem is in GLB, it can not compile or create the xcode project.
Instead of word, perhaps you need to make a video from start to finish of how you do it. :whistle:
Oh, it is really easy to know what I am doing...
This program:
// --------------------------------- //
// Project: Test
// Start: Thursday, February 24, 2011
// IDE Version: 9.006
// SETCURRENTDIR("Media") // seperate media and binaries?
ad_animate()
FUNCTION ad_animate:
glb_BannerInit()
WHILE TRUE
PRINT "AdBanner Test", 10, 100
SHOWSCREEN
WEND
ENDFUNCTION
?IFDEF IPHONE
IMPORT "C" void glb_BannerInit()
?ELSE
FUNCTION glb_BannerInit:
DEBUG "[WIN] Banner Init (sim) \n"
ENDFUNCTION
?ENDIF
INLINE
// .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];
}
ENDINLINE
Then I press F5 in GLBasic and get this error:
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.826 SN:bf7232e1 - 3D, NET
Wordcount:8 commands
compiling:
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:140:29: iAd/ADBannerView.h: No such file or directory
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:144: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:144: error: `interface' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:156: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:156: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:158: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:158: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:160: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:160: error: expected constructor, destructor, or type conversion before '(' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:164: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:166: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:168: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:170: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:176: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:188:30: AppViewController.h: No such file or directory
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:192: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:176: error: `end' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:196: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:198: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:198: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:200: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:200: error: `synthesize' does not name a type
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:212: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:222: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:248: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:290: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:310: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:312: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:322: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:328: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:338: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:374: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:382: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:392: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:414: error: expected unqualified-id before '-' token
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:418: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:426: error: stray '@' in program
C:\Users\AMpos\AppData\Local\Temp\glbasic\gpc_temp0.cpp:432: error: expected constructor, destructor, or type conversion before "extern"
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.2 sec. Time: 10:45
Build: 0 succeeded.
*** 1 FAILED ***
(I am at work now and have not access to any mac)
You don't add the objective-C files (aka ADBannerView.h, and ADBannerview.mm) in GLBasic. In GLBasic, all you do is use the IMPORT command.
Then, when you've compiled your XCode project, you add these objective-C files in XCode in the way matchy described before.
- Add the iAd files in XCode not GLBasic!
Example:
(http://www.coconutcollege.net/images/xcode_groups_classes.png)
Well...I'm off to have some cheesecake now. :rant:
the gbas files are compiled as C++ files. You must make the objC code in a .m or .mm file, and then:
REQUIRE "iphonestuff.mm"
IMPORT "C" void IPhoneStuff()
Everytime one of you talk, make it worse ;/
What is this "make objC" thing you are talking?
Again you are supousing I understand C, and again, I said I have ZERO idea of C. :giveup:
what is "iphonestuff.mm" and where should I put it?
I am at work and I have not access to my mac. Can someone sent me the ADBannerView.h and ADBannerview.mm files, so I can continue testing?
...and with strawberry topping too. :zzz:
That's why posted an image but obvious tutorial video is required. ;/
I'm very glad GLBasic itself seems so easy, that you are able to write such a cool game as the Krakout remake.
Can someone please do a video of how to put the iADs in a GLBasic app?
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 )
Quote from: Kitty Hello 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
?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.
Quote from: Kitty Hello 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:
What about a music only video tutorial (not speaking) or would screen shot steps be better? :|
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.
The only thing you seem to be doing wrong:
At the end of your GLBasic file you have this as INLINE code:
// .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:
That's what I call an explanation!
Will test later at home...
I've updated the procedure steps:
http://www.glbasic.com/forum/index.php?topic=4664.msg45421#msg45421
Quote from: matchy on 2011-Feb-24
I've updated the procedure steps:
http://www.glbasic.com/forum/index.php?topic=4664.msg45421#msg45421
Thanks a lot!
:nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw:
¿Lo has probado ya, ampos?, ¿te ha funcionado?.
Hasta esta noche no... ¡la siesta es sagrada!
Dí que sí hombre, el día que lo descubran éstos lo van a flipar. :bed:
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
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...
Found!
Change only the value
self.view.frame = CGRectMake(0,430, 768, 66);
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:
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.
That's great stuff! Works brilliantly. Quick question though; how do you use the showBanner and hideBanner functions? Basically I want to start the iAd immediately but on some screens I need the real estate and want to hide it. I tried mucking about with the .mm file by adding the following to the bottom:-
extern "C" void glb_ShowBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic showBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}
extern "C" void glb_HideBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic hideBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}
Thinking it would work like the init function, but they don't seem to do anything at all. It all compiles ok in XCode and the GLB import code looks correct, but nothing happens. I'm betting what I did is massively incorrect, so any help would be appreciated!
Cheers
:coke: I'm thirsty.
Yes, I have left the code for hiding the banner although I haven't perfect keeping the class, which only needs to allocation and initialization once. It also needs source for detecting banner touch and app pausing which I was hesitant about when submitting to the App Store. Have a look a trucidare's recent Bluetooth ObjC source for tips on how to call other functions after the Viewcontroller alloc and init.
Simply, I'm guessing but it should be like:
extern "C" void glb_HideBanner() {
[UIGlbasic hideBanner];
}
It looks like my original code above is firing the HideBanner function (I unremmed the NSLog line and it appears in the console), it just doesn't do much as it stands. If it makes any difference I modified the location of the iAd, using the same code you supplied, to appear at the bottom of the screen. So far though the hideBanner routine is doing the NSLog output to the console and that's about it. I've tried a few things but no luck so far.
Cheers
Here https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/8.0.0.9.1.7.1.1.7.1 (https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/8.0.0.9.1.7.1.1.7.1) Apple says
QuoteCan I join the iAd Network and serve iAd advertising for my iOS 3 application?
Ads from the iAd Network can only run on iOS apps built with iOS SDK 4 and target iOS 4 as the minimum OS.
So, any iOS 4.x should open iADs apps. Do you know why it crash in all iOS but 4.2.1?
(also, I "forgot" to set my app as iOS 4 minimun, I don't know how Apple approved it...)
As I noted before, Matchy's implkementation of iAD only works in 4.2.1, but it should on all 4.x
MSX note me that the funciton "ADBannerContentSizeIdentifierPortrait" was only in 4.2.1, and previously "ADBannerContentSizeIdentifier320x50" was used in 4.0, so I changed "...Portrait" with "...320x50" and tested in a 3GS 4.0.1, and... at least, it did not crash, but it also "does not work".
If someone can point me on the right direction, I will made more tests...
Hey everyone, Ampos is doing very well at implementing iAdBanners although he's need to set a weak link for the iAd framework library for backwards iOS compatibility.
http://developer.apple.com/library/ios/#recipes/XcodeRecipes/Linking_to_Libraries_and_Frameworks/Linking_to_Libraries_and_Frameworks.html
Example:
(http://useyourloaf.com/storage/post-images/2010-07-12-003.png?__SQUARESPACE_CACHEVERSION=1279058076956)
Quote from: matchy on 2011-Mar-09
Hey everyone, Ampos is doing very well at implementing iAdBanners although he's need to set a weak link for the iAd framework library for backwards iOS compatibility.
http://developer.apple.com/library/ios/#recipes/XcodeRecipes/Linking_to_Libraries_and_Frameworks/Linking_to_Libraries_and_Frameworks.html
Example:
(http://useyourloaf.com/storage/post-images/2010-07-12-003.png?__SQUARESPACE_CACHEVERSION=1279058076956)
I see... but perhaps this weak is only if you want your app to be run on 3.x iOS (without iADs), but I dont want to. If possible, I want to make it 4.x capable (a iADs are a 4.x thing), not only 4.2.1 as now.
Or maybe I am wrong...
[EDIT]Sorry :offtopic:[/EDIT]
On a sales point of view, it's not like people are going to upgrade specifically to run your app (if you ONLY allow 4.2.1 and higher for the use of iAds), and likewise people aren't going to downgrade to something below that just to avoid having iAds in your app.
You'd might as well allow users whose devices are less than 4.2.1 to install your app - even if its free, and will be ad free on their devices. The worst they can do is spread knowledge of it to users who will have iAds.
The issue of compatibility is non-GLB related (same for pure xcode apps) and there is no point in discussing general concerns here.
Excuse me if I did sound rude.
But iADs is compatible from 4.0 upwards, but Matchy's solution is just 4.2.1 (latest). I am just asking if someone with more knowledge than me can fix it, or if it can be fixed.
Matchy has used (AFAIK) one call that is only in 4.2.1 ("ADBannerContentSizeIdentifierPortrait"), and there seems to be similar ones in 4.0 (""ADBannerContentSizeIdentifier320x50").
Sorry, guys, but everything I said you take it as an attack. And it is not.
First, I greatly appreciate Matchy and everyone else work. I will be using what you give us.
Serpent, it is not only my app that will be forced to be 4.2.1, but everyone's app that uses the current and only one (yet) solution of iADs on GLBasic. So, if it is fixed, we all will be beneficiated. I am not telling "upgrade to 4.2.1 to use my app" as it (my app) is crap. In my app description I am saying "sorry guys, but it only works in 4.2.1"
If it can be fixed to work on every 4.x iOS, I dont understand why it shouldn't, at least, did try to be fixed. But if it cant not, or there is not enough knowledge to fix it, I can (and will) live with it. I am sorry for not having enough knowledge to do it by myself.
Meanwhile, guys, again, thank you all for your work and help.
Quote from: ampos on 2011-Mar-09
Excuse me if I did sound rude.
But iADs is compatible from 4.0 upwards, but Matchy's solution is just 4.2.1 (latest). I am just asking if someone with more knowledge than me can fix it, or if it can be fixed.
Matchy has used (AFAIK) one call that is only in 4.2.1 ("ADBannerContentSizeIdentifierPortrait"), and there seems to be similar ones in 4.0 (""ADBannerContentSizeIdentifier320x50").
Sorry, guys, but everything I said you take it as an attack. And it is not.
Ampos is still talking in third to others but not me, but all is good...no offence taken by me at least because I appreciate your persistance. It's the only way to learn and that how I did it over months and months. There's no short cut even if others know....google is your friend.
Anyhow, back to the technical stuff; ADBannerContentSizeIdentifier320x50 is depreciated so use ADBannerContentSizeIdentifierPortrait because of ipad (tested) resolution.
Matchy, there is more people on this forum with knowledge of C than you... :nana:
As I see, to use ...portrait is only advisable if your app is universal, but if it only use standard resolution, is better to use ...320x50 for backwards compatibility.
As I see, it could better something like
IF resolution>320
...portrait
ELSE
...320x50
ENDIF
Of course, in C :)
But first we (as I am not the only one that will use this in the future!) need the <4.2.1 thing working.
Althoug, Matchy, the real question here is: do you want to make your iAD implementation 4.x compatible? If you dont, further talk is futile.
Who cares what people know if they haven't posted in this thread, so enough of the politics please.
I'm not sure what the issue is as I have tested iAd on 3.0 to 4.2 devices and it works ok.
Again, your issue can be solved on a Cocoa/xcode forum rather than here because it has NOTHING to do with GLB.
How I should do to use it in landscape mode (in the bottom)?
I have tried without no luck.
any tip?
Thanks in advance.
This code is for fixed portrait only as that is how it was released for the first iAd app. For now, rotation orientation tests okay so removing the commenting from the class methods and modifying shouldAutorotateToInterfaceOrientation and willRotateToInterfaceOrientation to set the default fixed orientation. :)
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:
/*
* 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...
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
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
I had it working properly at the bottom on my app...
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
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".
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
Strange, it works fine in my iphone 4 4.3...
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
Yes and yes.
Perhaps it is something with it showing TEST ADS for me instead of ads...
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]
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.
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
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.
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.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
In the spanish forums, we have the files modified to get iADs working for any iOS 4.x
http://www.glbasic.com/forum/index.php?topic=5932.new;topicseen#new
Thanks to msx2 for the modifications.
Any help about landscape mode?
I have tried several solutions without luck.
Quote from: Crivens 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
Tested with SDK 4.2 and SDK 4.3 and shows the same bug, but only in IOS 4.3. It works without problems in iOS 4.1.
Oh my.
Trucidare!?
I posted code earlier in this thread to allow it to work with adverts if at the top of the screen. I only hacked it together but it seems to work. Try the Rotaslider free version to see it working.
Cheers
Ok, so my modified version I posted earlier in this thread allows iAds to work properly after being selected (ie. rest of screen doesn't freeze up), or at least if you only use an iAd at the top of the screen it works (anyone fixed that?), but has anyone implemented ads in WebOS or Android?
Cheers
Quote from: Crivens on 2011-Aug-03
Ok, so my modified version I posted earlier in this thread allows iAds to work properly after being selected (ie. rest of screen doesn't freeze up), or at least if you only use an iAd at the top of the screen it works (anyone fixed that?), but has anyone implemented ads in WebOS or Android?
Cheers
I am really lost here... which one is the good version?
I mean, Crivens seems to have fix some kind of error on wrapper after pressing the iAD and I can not find in this thread his modification, and we have in the spanish forum http://www.glbasic.com/forum/index.php?topic=5932.0 a version that works on any 4.x (Matchy's original code just worked only in 4.2+).
It could be great if a new post about iADs is created with the source code in the very first post with both fixes implemented.
It's in here somewhere. Is very slightly changed. While it fixes ads at the top of the screen so it doesn't all freeze after selection, it doesn't quite work for if the ad is at the bottom of the screen
Cheers
Seriously, I dont see anything modified by you in this thread...
Hmm, I will have a look tomorrow. Definitely posted it plus it's being used in the free Rotaslider app.
Cheers
Strange I could swear I posted the full code but can't find it now. Perhaps in a different thread. I do describe the fix though:-
QuoteHmm, 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'll dig out the code tomorrow and post it here.
Cheers
Ok, think I've found the right version of AppViewController.mm. As I said before I only fiddled with it a bit and got it to work (ie. unfreeze after selection) for an ad at the top of the screen. One at the bottom doesn't quite work after selection (it unfreezes but the iAd itself isn't selectable anymore and any "clicks" will select underneath the iAd.
// 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];
self.view.frame = CGRectMake(0,0, 768, 50);
bannerView.frame=CGRectMake(0,0, 768, 50);
//self.view.frame = CGRectMake(0,480-50, 768, 50);
//bannerView.frame=CGRectMake(0,480+50, 768, 50);
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 {
NSLog(@"changeBannerOrientation");
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,480-50, 768, 50);
//bannerView.frame=CGRectMake(0,480+50, 768, 50);
self.view.frame = CGRectMake(0,0, 768, 50);
bannerView.frame=CGRectMake(0,0, 768, 50);
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];
}
extern "C" void glb_ShowBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic showBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}
extern "C" void glb_HideBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic hideBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}
Cheers
Since iOS 5.x I have found that my app display a white box when the iAD were not loaded.
Last week I updated the app and sent it to Apple. They have rejected it because this white box.
Perhaps someone could update our parser to avoid this problem.
Quote from Apple:
Quote7.2
We found that your app displays an empty iAd banner when ad content is not available, which is not in compliance with the App Store Review Guidelines.
Please see the attached screenshot/s for more information.
The banner within the app should be hidden whenever ad content is not being served by iAd. To handle the case where ad content is not available, you need to implement a banner view delegate. An example code snippet is included here for your convenience. Additionally, you may wish to review the section "Working with Banner Views" of the iAd Programming Guide.
Banner View Delegate to Remove a Banner View When Advertisements are Not Available:
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
Yeah I can see that with mine. Plus the iAds don't show until you exit the app and then restart it. It's still there and you can click it but can't see it until restart.
Unfortuantly I'm moving to paid only apps for a bit to see how that pans out with sales, so I'm not bothered with iAds for the moment. Hopefully someone else can make a 100% ios5 compatible iad wrapper.
Cheers
Has anyone managed to solve this problem?. Does it show banners with this code on IOS 5 or else only a white box?.
Thank you :good: