ios - Tableview with custom UIView , adding labels overlaps -


i trying implement ibooks bookshelf functionality , use gsbookshelf pretty simple , straight forward, adds button cells , works great.

i want add labels each button, succeed once in while lets 2 out of 5 times labels overlaps previous buttons label.

normally normally this

sometime happens: sometime happens

code:

- (uiview *)bookshelfview:(gsbookshelfview *)bookshelfview bookviewatindex:(nsinteger)index {      nsdictionary *currentarticle = [_bookarray objectatindex:index];      static nsstring *identifier = @"bookview";     mybookview *bookview = (mybookview *)[bookshelfview dequeuereuseablebookviewwithidentifier:identifier];     if (bookview == nil) {         bookview = [[mybookview alloc] initwithframe:cgrectzero];         bookview.reuseidentifier = identifier;         [bookview addtarget:self action:@selector(bookviewclicked:) forcontrolevents:uicontroleventtouchupinside];      }     [bookview setindex:index];     [bookview setselected:[(nsnumber *)[_bookstatus objectatindex:index] intvalue]];     //[bookview setfilename:[currentarticle objectforkey:@"name"] ];     //[bookview setfilename:[currentarticle objectforkey:@"name"] :index];      uiimage *image = nil;     image = [self returncellimagefor:[currentarticle objectforkey:@"imagename"]];     [bookview setbackgroundimage:image forstate:uicontrolstatenormal];      uilabel *_filelabel=nil;     _filelabel =[[uilabel alloc] initwithframe:cgrectmake(0, 180, 200, 46)];     _filelabel.text=[currentarticle objectforkey:@"name"];     _filelabel.textcolor=[uicolor whitecolor];     _filelabel.backgroundcolor=[uicolor clearcolor];     _filelabel.font = [uifont fontwithname:@"gill sans" size:16];     //_filelabel.textalignment=uitextalignmentcenter;     _filelabel.textalignment = nstextalignmentcenter;     _filelabel.numberoflines=0;     _filelabel.linebreakmode = uilinebreakmodewordwrap;     [_filelabel sizetofit];     [bookview addsubview:_filelabel];      return bookview; } 

images never overlap label sometimes.

any idea why happening?

where did put bookshelfview function at? show tableview code. bet problem have when scroll down in table bookshelfview being called again. label being created twice 2 different values.

that's way see overlap happening, being initiated on , on again

_filelabel =[[uilabel alloc] initwithframe:cgrectmake(0, 180, 200, 46)]; 

i check tableview code. had asked similar question before. (not exact). check out uitableview , uilabel repeating


Comments