Monday, 20 July 2015

Need help integrating admobs into an app


code:
//  fixmybiketoappdelegate.h      #import <uikit/uikit.h>    #import "admobdelegateprotocol.h"       @class rankviewcontroller;       @interface fixmybiketoappdelegate : nsobject <uiapplicationdelegate,admobdelegate> {    uiview *mainview;        uiwindow *window;    uinavigationcontroller *nav;    rankviewcontroller *root;     }       - (void) loadmainwindow;       @property (nonatomic, retain) uiview *mainview;    @property (nonatomic, retain) iboutlet uiwindow *window;    @property (nonatomic, retain) uinavigationcontroller *nav;    @property (nonatomic, retain) rankviewcontroller *root;          @end    ------------------------------------------------------------------------------------------------------------------------------------------        //  fixmybiketoappdelegate.m        #import <corelocation/corelocation.h>    #import "fixmybiketoappdelegate.h"    #import "rankviewcontroller.h"    #import "bikestorestableviewcontroller.h"    #import "admobdelegateprotocol.h"    #import "admobview.h"    #import "adviewcontroller.h"       @implementation fixmybiketoappdelegate       @synthesize window, nav, root, mainview;       - (void)dealloc {    [nav release];    [mainview release];        [window release];        [super dealloc];    }       - (void)applicationdidfinishlaunching:(uiapplication *)application {           rankviewcontroller *rootcontroller = [[rankviewcontroller alloc] init];    self.root = rootcontroller;    [rootcontroller release];       uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:root];    [[navcontroller navigationbar] setbarstyle:uibarstyleblackopaque];    self.nav = navcontroller;    [navcontroller release];       [window setbackgroundcolor:[uicolor blackcolor]];       mainview = [[uiview alloc] initwithframe:cgrectmake(0,0,320,480)];    [mainview clipstobounds];       uiimageview *background = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"smiletemp.png"]];    [mainview addsubview:background];    [window addsubview:mainview];    // [window addsubview:background];    [background release];       //admobview *ad = [admobview requestadwithdelegate:self]; // start new ad request    //ad.frame = cgrectmake(0, 432, 320, 48); // set frame, in case @ bottom of screen    //[window addsubview:ad]; // attach ad view hierarchy; self.window responsible retaining ad    /*     uilabel *name = [[uilabel alloc] initwithframe:cgrectmake(10,10,50,50)];    [name setfont:[uifont fontwithname:@"helveticaneue-bold" size:24]];    [name settext:@"test"];    [window addsubview:name];    [name release];    */     [self performselector:@selector(loadmainwindow) withobject:nil afterdelay:3.0];    // [mainview addsubview:self.nav.view];        [window makekeyandvisible];       }       - (void)loadmainwindow {    [[mainview.subviews objectatindex:0] removefromsuperview];    [mainview addsubview:self.nav.view];    }          - (void)applicationwillterminate:(uiapplication *)application {       // save preferences , current state...    nsuserdefaults *userdefaults = [nsuserdefaults standarduserdefaults];    [userdefaults synchronize];       }             #pragma mark -    #pragma mark admobdelegate methods       - (nsstring *)publisherid {    return @"a14b4d0e8fb6036"; // should prefilled; if not, [url]www.admob.com[/url]    }       - (bool)usetestad;     {     return no;     }       - (uicolor *)adbackgroundcolor {    return [uicolor colorwithred:0.8 green:0 blue:0 alpha:1]; // should prefilled; if not, provide uicolor    }       - (uicolor *)primarytextcolor {    return [uicolor colorwithred:1 green:1 blue:1 alpha:1]; // should prefilled; if not, provide uicolor    }       - (uicolor *)secondarytextcolor {    return [uicolor colorwithred:1 green:1 blue:1 alpha:1]; // should prefilled; if not, provide uicolor    }       - (bool)mayaskforlocation {    return yes; // should prefilled; if not, see admobprotocoldelegate.h instructions    }    @end      ------------------------------------------------------------------------------------------------------------------------------------------    // view displays banner ads.  minimum implementation ad    // within uiviewcontroller class is:    //    //   // place ad @ top of screen of iphone/ipod touch.    //   cgrect adframe = cgrectzero;    //   adframe.size = gad_size_320x50;    //    //   // create , setup ad view.    //   gadbannerview *adview = [[gadbannerview alloc] initwithframe:adframe];    //   adview.rootviewcontroller = self;    //   adview.adunitid = @"id created when registering app";    //    //   // place ad view onto screen.    //   [self.view addsubview:adview];    //   [adview release];    //    //   // request ad without additional targeting information.    //   [adview loadrequest:nil];

i'm trying (new admob code right above) in original code, there seems incompatiblity. new version uses uiviewcontroller, older version of admobs uses uiview display ad. there way convert uiviewcontroller uiview?


first 2 files shown above older version of admobs implemented in original code.


in advance.
 

the fact ask question shows don't understand important difference between two. i'd suggest go learn more how differ.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment