uitableview - UITableViewCell wrap text in UINavigationController app -


i having tableview different heights each cell based on size of text. calculate rowsize in delegate method -tableview:heightforrowatindexpath, , assign text in datasource method -tableview:cellforrowatindexpath. able realize appropriate height based on text, not able make text wrap around; instead disappears off screen. using navigation-based app generate tableview in child view controller using nib. played around of options tableview, can't make text wrap. see next wrap if textview, want entire content displayed in cell, without scroll bars in table cell itself. possible?

here updated code, height adjusting correctly, cell not word wrapping...

-

(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {      nsstring *string = [self.quizdictionary objectforkey:[_temp objectatindex:testkv]];      cgsize stringsize = [string sizewithfont:[uifont boldsystemfontofsize:15]                           constrainedtosize:cgsizemake(320, 9999)                                linebreakmode:uilinebreakmodewordwrap];     return stringsize.height+25; }    - (uitableviewcell *)tableview:(uitableview *)tableview           cellforrowatindexpath:(nsindexpath *)indexpath {      int row = indexpath.row;     if (row > 6) {         return nil;     }     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[[uitableviewcell alloc]                   initwithstyle:uitableviewcellstyledefault                   reuseidentifier:cellidentifier]                  autorelease];         }      // configure cell...     nsstring *string = [self getquestionpart];      cgsize stringsize = [string sizewithfont:[uifont boldsystemfontofsize:15] constrainedtosize:cgsizemake(320, 9999) linebreakmode:uilinebreakmodewordwrap];     uitextview *textv=[[uilabel alloc] initwithframe:cgrectmake(5, 5, 290, stringsize.height+10)];     textv.font = [uifont systemfontofsize:15.0];     textv.text=string;     textv.textcolor=[uicolor blackcolor];  // textv.editable=no;     [cell.contentview addsubview:textv];     [textv release];     testkv++;      return cell; } 

you want:

cell.textlabel.linebreakmode = uilinebreakmodewordwrap; 

to text wrap within cell. in combination careful implementation of tableview:heightforrowatindexpath: should trick.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -