ios - Different GADBannerView in TableView -


i want have uitableview contains admob banner every 13th cell. work, problem want show different banners (4 @ moment). @ cell 13 have banner 1 , @ cell 26 banner 2 , on.

my problem is, don't know how realize that. receive first banner in every cell - - guess - means code loads 1 banner in every cell , says "yep. have ad. i'm happy" , not loads 2 banner in 26 cell.

i did subclass "adcell" , have bool says "hasad" prevent every cell reloads when scrolling (but maybe part of problem?). maybe can me.

the cell in table:

   adcell *cell = (adcell *)[tableview dequeuereusablecellwithidentifier:@"adcell"];     cell.tag = 4;     if (cell == nil) {         cell = [[adcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"adcell"];      }      if (![cell hasad]){          // create view of standard size @ bottom of screen.         // available adsize constants explained in gadadsize.h.         gadadsize customadsize = gadadsizefromcgsize(cgsizemake(290, 120));          dfpbannerview *bannerview_ = [[dfpbannerview alloc] initwithadsize:customadsize];          //the adcounter said banner1,banner2          if (adcounter == 4){             adcounter = 1;         }         bannerview_.adunitid = [nsstring stringwithformat:@"leftout-%i/banner",adcounter];          // let runtime know uiviewcontroller restore after taking         // user wherever ad goes , add view hierarchy.         bannerview_.rootviewcontroller = self;          //center ad         [bannerview_ setcenter:cgpointmake(cell.center.x, cell.center.y)];          [cell.contentview addsubview:bannerview_];         // initiate generic request load ad.         [bannerview_ loadrequest:[gadrequest request]];           adcounter++;          [cell sethasad];     }        return cell; 

in cellforrowatindexpath: method, check indexpath.row value. if it's divisible 13, load ad cell.

you extend technique check ad load - if it's row 26, 26 % 13 = 2, load ad #2 , on.

putting logic in cell subclass violates model-view-controller pattern - cells dumb recipients of data , it's uitableviewcontroller class decides should display.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -