Why is my Admob banner not showing? using storyboard -
can me correcting mistake in code, can't find myself, think seems fine, no ads showing. thanks!
#import "viewcontroller.h" #import "gadbannerview.h" #import "gadrequest.h" @implementation viewcontroller @synthesize adbanner = adbanner_; - (uiview *)view { return (uiview *)self.view; } - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { // initialization code } return self; } #pragma mark init/dealloc // implement viewdidload additional setup after loading view, // typically nib. - (void)viewdidload { // initialize banner @ bottom of screen. cgpoint origin = cgpointmake(0.0, self.view.frame.size.height - cgsizefromgadadsize(kgadadsizebanner).height); // use predefined gadadsize constants define gadbannerview. self.adbanner = [[gadbannerview alloc] initwithadsize:kgadadsizebanner origin:origin]; // note: edit sampleconstants.h provide definition ksampleadunitid // before compiling. self.adbanner.adunitid = @"a15217a5a9b32c4"; self.adbanner.delegate = self; [self.adbanner setrootviewcontroller:self]; [self.view addsubview:self.adbanner]; self.adbanner.center = cgpointmake(self.window.center.x, self.adbanner.center.y); [self.adbanner loadrequest:[self createrequest]]; } - (void)dealloc { adbanner_.delegate = nil; } - (nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmaskportrait; } #pragma mark gadrequest generation // here we're creating simple gadrequest , whitelisting application // test ads. should request test ads during development avoid // generating invalid impressions , clicks. - (gadrequest *)createrequest { gadrequest *request = [gadrequest request]; // make request test ad. put in identifier simulator // devices want receive test ads. request.testdevices = [nsarray arraywithobjects: @"3a8012a2-66b8-52f0-8426-2d4cd8d51444", nil]; return request; } #pragma mark gadbannerviewdelegate impl // we've received ad successfully. - (void)adviewdidreceivead:(gadbannerview *)adview { nslog(@"received ad successfully"); } - (void)adview:(gadbannerview *)view didfailtoreceiveadwitherror:(gadrequesterror *)error { nslog(@"failed receive ad error: %@", [error localizedfailurereason]); } @end
i using storyboard, , i've been searching net solution don't seem find usefull.
Comments
Post a Comment