iAd in iPhone animates when not loaded -
i have added banner view implementing iad in bottom of screen. when running on simulator banner view above frame fixed it. appears transparent strip , not selectable. after sometime automatically comes bottom black strip saying test advertisement.
i want banner view stick bottom , not animate.
here code. adview declaration code:
adview = [[[adbannerview alloc] initwithframe:cgrectoffset(cgrectzero, 0, 350)] autorelease]; adview.frame = cgrectmake(0,340,320,25); adview.requiredcontentsizeidentifiers = [nsset setwithobject:adbannercontentsizeidentifier320x50]; adview.currentcontentsizeidentifier = adbannercontentsizeidentifier320x50; adview.autoresizingmask = uiviewautoresizingflexibletopmargin | uiviewautoresizingflexiblerightmargin; adview.tag = 111; [self.navigationcontroller.view addsubview:adview]; adview.delegate = self; self.bannerisvisible = no; adview.hidden = yes;
here delegate methods.
- (void)bannerviewdidloadad:(adbannerview *)banner { if (!self.bannerisvisible) { [uiview beginanimations:@"animateadbanneroff" context:null]; // banner invisible , moved out of screen on 50 px banner.frame = cgrectoffset(banner.frame, 0, 50); [uiview commitanimations]; self.bannerisvisible = yes; } } // when iad not availale on banner - (void)bannerview:(adbannerview *)banner didfailtoreceiveadwitherror:(nserror *)error { if (self.bannerisvisible) { [uiview beginanimations:@"animateadbanneroff" context:null]; // banner visible , move out of screen, due connection issue banner.frame = cgrectoffset(banner.frame, 0, 520); [uiview commitanimations]; self.bannerisvisible = no; } }
i not able understand problem. kindly help.
first. when main view loaded how objects placed in initially? place them in right positions inside viewdidload
method. place banner below bottom of main view making sure that
mybannerframe.origin.x = 0; mybannerframe.origin.y = mainview.frame.size.height; [mybanner setframe:mybannerframe]; // no need animation here!
also viewdidload
place set flag self.bannerisvisible
false
.
second. not use fixed pixel values here
banner.frame = cgrectoffset(banner.frame, 0, 50);
instead of 50
better put banner.frame.size.height
avoid many errors , misalignments.
Comments
Post a Comment