ios - Struggling with integrating iAd -
i have tab bar application have table views sub views. need show ad banner @ bottom above tab bar. ad banner seen , not long time. leaves white view when not available , not. not getting happening here:
i using:
- (void)viewdidload { [super viewdidload]; cgrect frame=cgrectzero; frame.size = [adbannerview sizefrombannercontentsizeidentifier:adbannercontentsizeidentifierportrait]; // place frame @ bottom edge of screen out of sight frame.origin = cgpointmake(0.0, 317); // create , configure banner view adbannerview *adview = [[adbannerview alloc] initwithframe:frame]; adview.requiredcontentsizeidentifiers = [nsset setwithobject:adbannercontentsizeidentifierportrait]; // set delegate self, notified of ad responses adview.delegate = self; adview.hidden = yes; [self.view addsubview: adview]; } - (void)bannerviewdidloadad:(adbannerview *)banner { nslog(@"ad available"); banner.hidden = no; // brand new frame cgrect newframe=cgrectzero; cgpoint frameorigin=cgpointzero; // set origin frameorigin=cgpointmake(0.0, cgrectgetmaxy(self.view.bounds)); newframe.origin=frameorigin; // set size newframe.size=[adbannerview sizefrombannercontentsizeidentifier:adbannercontentsizeidentifierportrait]; cgfloat bannerheight = newframe.size.height; cgfloat banneroffset=0.0; // determine new frame should if (!self.isbannervisible) { // should visible, raise banneroffset=-bannerheight; } cgrect offsetrect=cgrectoffset(newframe,0.0f,banneroffset); [uiview animatewithduration:0.2 animations:^{banner.frame= offsetrect;} completion:^(bool finished){ if (banneroffset<0){ self.isbannervisible=yes; }else{ self.isbannervisible=no; } } ]; } - (void)bannerview:(adbannerview *)banner didfailtoreceiveadwitherror:(nserror *)error { nslog(@"error is===>%@",error); } - (bool)bannerviewactionshouldbegin:(adbannerview *)banner willleaveapplication:(bool)willleave { return yes; }
sometimes error is:
error domain=aderrordomain code=0 "the operation couldn’t completed. unknown error" userinfo=0x8c53410 {adinternalerrorcode=0, adinternalerrordomain=aderrordomain, nslocalizedfailurereason=unknown error}
sometimes is:
error domain=aderrordomain code=3 "the operation couldn’t completed. ad inventory unavailable" userinfo=0x7e64780 {adinternalerrorcode=3, adinternalerrordomain=aderrordomain, nslocalizedfailurereason=ad inventory unavailable}
please help!!
Comments
Post a Comment