Discussion Forums  >  Xcode, Errors, Installing, Configuring

Replies: 10    Views: 203

ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
07/20/12 12:05 PM (13 years ago)

Need quick help with iOS admob

###### Ok so im stuck on this part 2. Open the BT_viewController.m and scroll down or search for the method -(void)createAdBannerView 2.1 You need to comment (GIYF) or delete everything inside this method (void)createAdBannerView{ EVERYTHING INSIDE HERE SHOULD BE COMMENTED OR DELETED } 2.2 Replace the commented or deleted content with this one: //AdMob // Create a view of the standard size at the bottom of the screen. bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height -44, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; // Specify the ad's "unit identifier." This is your AdMob Publisher ID. bannerView_.adUnitID = @"XXXXXXXXXXXX"; // Let the runtime know which UIViewController to restore after taking // the user wherever the ad goes and add it to the view hierarchy. bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; // Initiate a generic request to load it with an ad. [bannerView_ loadRequest:[GADRequest request]]; [bannerView_ release]; ########################## How should it look, im copy and pasting the parts in the bt viewcontroller.m and i need help on what to delete and replace ########################## //createAdBannerView -(void)createAdBannerView{ Class classAdBannerView = NSClassFromString(@"ADBannerView"); if(classAdBannerView != nil){ [BT_debugger showIt:self:[NSString stringWithFormat:@"createiAdBannerView: %@", @""]]; self.adView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; self.adView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth); [self.adView setTag:94]; self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease]; [self.adBannerView setDelegate:self]; [self.adBannerView setTag:955]; if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { [adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape]; }else{ [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; } [self.adView setFrame:[BT_viewUtilities frameForAdView:self:screenData]]; [adView setBackgroundColor:[UIColor clearColor]]; [self.adView addSubview:self.adBannerView]; [self.view addSubview:adView]; [self.view bringSubviewToFront:adView]; } } //showHideAdView -(void)showHideAdView{ [BT_debugger showIt:self:[NSString stringWithFormat:@"showHideAdView: %@", @""]]; if(adBannerView != nil){ //we may need to change the banner ad layout if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape]; }else{ [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; } [UIView beginAnimations:@"positioniAdView" context:nil]; [UIView setAnimationDuration:1.5]; if(adBannerViewIsVisible){ [self.adView setAlpha:1.0]; }else{ [self.adView setAlpha:.0]; } [UIView commitAnimations]; } } //banner view did load... -(void)bannerViewDidLoadAd:(ADBannerView *)banner{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd bannerViewDidLoadAd%@", @""]]; if(!adBannerViewIsVisible) { adBannerViewIsVisible = YES; [self showHideAdView]; } } //banner view failed to get add -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd didFailToReceiveAdWithError: %@", [error localizedDescription]]]; if (adBannerViewIsVisible){ adBannerViewIsVisible = NO; [self showHideAdView]; } } //shouldAutorotateToInterfaceOrientation -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } //didReceiveMemoryWarning -(void)didReceiveMemoryWarning{ [BT_debugger showIt:self:[NSString stringWithFormat:@"appDelegate didReceiveMemoryWarning%@", @""]]; } @end
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
07/20/12 12:40 PM (13 years ago)
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
07/20/12 12:43 PM (13 years ago)
thats where i looked thats what i copy and pasted in my original post
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
07/20/12 12:55 PM (13 years ago)
I think I know where you have gone wrong: Also I have my GAD_SIZE_320x50.height -92 on mine, it looks like this: // Class classAdBannerView = NSClassFromString(@"ADBannerView"); // if(classAdBannerView != nil){ // [BT_debugger showIt:self:[NSString stringWithFormat:@"createiAdBannerView: %@", @""]]; // self.adView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; // self.adView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth); // [self.adView setTag:94]; // self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease]; // [self.adBannerView setDelegate:self]; // [self.adBannerView setTag:955]; // if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { // [adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape]; // }else{ // [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; // } // [self.adView setFrame:[BT_viewUtilities frameForAdView:self:screenData]]; // [adView setBackgroundColor:[UIColor clearColor]]; // [self.adView addSubview:self.adBannerView]; // [self.view addSubview:adView]; // [self.view bringSubviewToFront:adView]; // // } }
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
07/20/12 04:24 PM (13 years ago)
hello Dragon, thank you for the replies. You said you think you know where i have gone wrong. I havent did anything yet, i just showed the first thing is what im supposed to put into my viewcontroller.m and the 2nd thing is the viewController.m file at the moment without anything done to it...thats where im stuck.
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
07/21/12 02:49 AM (13 years ago)
what does your whole viewcontroller.m file actually have so i can see what im doing wrong
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
07/21/12 05:01 AM (13 years ago)
My BT_viewController.m: /* * Copyright 2011, David Book, buzztouch.com * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice which includes the * name(s) of the copyright holders. It must also retain this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of David Book, or buzztouch.com nor the names of its contributors * may be used to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "GADBannerView.h" #import "iAd/ADBannerView.h" #import "JSON.h" #import "taylorjones_appDelegate.h" #import "BT_item.h" #import "BT_debugger.h" #import "BT_viewControllerManager.h" #import "BT_viewUtilities.h" #import "BT_viewController.h" @implementation BT_viewController @synthesize progressView, screenData; @synthesize adView, adBannerView, adBannerViewIsVisible; @synthesize hasStatusBar, hasNavBar, hasToolBar; //initWithScreenData -(id)initWithScreenData:(BT_item *)theScreenData{ if((self = [super init])){ [BT_debugger showIt:self:@"INIT"]; //set screen data [self setScreenData:theScreenData]; } return self; } //show progress -(void)showProgress{ [BT_debugger showIt:self:@"showProgress"]; //show progress view if not showing if(progressView == nil){ progressView = [BT_viewUtilities getProgressView:@""]; [self.view addSubview:progressView]; } } //hide progress -(void)hideProgress{ [BT_debugger showIt:self:@"hideProgress"]; //remove progress view if already showing if(progressView != nil){ [progressView removeFromSuperview]; progressView = nil; } } //left button -(void)navLeftTap{ [BT_debugger showIt:self:@"navLeftTap"]; //handle "left" transition [BT_viewControllerManager handleLeftButton:screenData]; } //right button -(void)navRightTap{ [BT_debugger showIt:self:@"navRightTap"]; //handle "right" transition [BT_viewControllerManager handleRightButton:screenData]; } //show audio controls -(void)showAudioControls{ [BT_debugger showIt:self:@"showAudioControls"]; //appDelegate taylorjones_appDelegate *appDelegate = (taylorjones_appDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate showAudioControls]; } //show alert -(void)showAlert:(NSString *)theTitle:(NSString *)theMessage:(int)alertTag{ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:theTitle message:theMessage delegate:self cancelButtonTitle:NSLocalizedString(@"ok", "OK") otherButtonTitles:nil]; [alertView setTag:alertTag]; [alertView show]; [alertView release]; } //"OK" clicks on UIAlertView - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ [BT_debugger showIt:self:[NSString stringWithFormat:@"alertView:clickedButtonAtIndex: %i", buttonIndex]]; //handles OK click after emailing an image from BT_screen_imageEmail if([alertView tag] == 99){ [self.navigationController popViewControllerAnimated:YES]; } //handles OK click after sharing from BT_screen_shareFacebook or BT_screen_shareTwitter if([alertView tag] == 199){ [self navLeftTap]; } } //////////////////////////////////////////// //Ad Size Methods //createAdBannerView -(void)createAdBannerView{ //AdMob // Create a view of the standard size at the bottom of the screen. bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height -92, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; // Specify the ad's "unit identifier." This is your AdMob Publisher ID. bannerView_.adUnitID = @"your admob id here"; // Let the runtime know which UIViewController to restore after taking // the user wherever the ad goes and add it to the view hierarchy. bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; // Initiate a generic request to load it with an ad. [bannerView_ loadRequest:[GADRequest request]]; [bannerView_ release]; // Class classAdBannerView = NSClassFromString(@"ADBannerView"); // if(classAdBannerView != nil){ // [BT_debugger showIt:self:[NSString stringWithFormat:@"createiAdBannerView: %@", @""]]; // self.adView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; // self.adView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth); // [self.adView setTag:94]; // self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease]; // [self.adBannerView setDelegate:self]; // [self.adBannerView setTag:955]; // if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { // [adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape]; // }else{ // [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; // } // [self.adView setFrame:[BT_viewUtilities frameForAdView:self:screenData]]; // [adView setBackgroundColor:[UIColor clearColor]]; // [self.adView addSubview:self.adBannerView]; // [self.view addSubview:adView]; // [self.view bringSubviewToFront:adView]; // // } } //showHideAdView -(void)showHideAdView{ [BT_debugger showIt:self:[NSString stringWithFormat:@"showHideAdView: %@", @""]]; if(adBannerView != nil){ //we may need to change the banner ad layout if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape]; }else{ [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; } [UIView beginAnimations:@"positioniAdView" context:nil]; [UIView setAnimationDuration:1.5]; if(adBannerViewIsVisible){ [self.adView setAlpha:1.0]; }else{ [self.adView setAlpha:.0]; } [UIView commitAnimations]; } } //banner view did load... -(void)bannerViewDidLoadAd:(ADBannerView *)banner{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd bannerViewDidLoadAd%@", @""]]; if(!adBannerViewIsVisible) { adBannerViewIsVisible = YES; [self showHideAdView]; } } //banner view failed to get add -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd didFailToReceiveAdWithError: %@", [error localizedDescription]]]; if (adBannerViewIsVisible){ adBannerViewIsVisible = NO; [self showHideAdView]; } } //shouldAutorotateToInterfaceOrientation -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } //didReceiveMemoryWarning -(void)didReceiveMemoryWarning{ [BT_debugger showIt:self:[NSString stringWithFormat:@"appDelegate didReceiveMemoryWarning%@", @""]]; } @end
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
07/21/12 10:51 AM (13 years ago)
thanks alot! im gonna see if it works and get back to u
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
07/21/12 11:33 AM (13 years ago)
Undefined symbols for architecture i386: "_AudioServicesPlaySystemSound", referenced from: -[GADWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] in libGoogleAdMobAds.a(GADWebViewDelegate.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) what do i do now... 2 errors
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
07/22/12 06:55 AM (13 years ago)
Have you added the AudioToolbox framework?
 
AlmaR
Lost but trying
Profile
Posts: 73
Reg: Jun 13, 2011
location unknow...
5,630
like
03/27/13 07:38 AM (12 years ago)
@ceerup you will also have to add AdSupport.framework. Good luck!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.