Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent a UITableViewCell's textLabel from truncating its text on iPad

I am using a UITableView on an iPad and for some reason the UITableViewCell.textLabel's text is getting truncated even though there's plenty of space to display the text. I tried all of the following, none of which fixed it:

  1. Set a flexible width autosizing mask on the cell
  2. Calling [cell sizeToFit] after setting the text
  3. Calling [cell.textLabel setNumberOfLines:0] and [cell.textLabel setLineBreakMode:NSLineBreakByWordWrapping]

I haven't yet tried subclassing UITableViewCell and setting the frame explicitly in the layoutSubviews method. Trying to avoid that as I feel like there should be a better solution. I also don't want to resize the text--there is plenty of space to fit the text at the full font size.

enter image description here

like image 277
Jamie Forrest Avatar asked Jun 06 '13 13:06

Jamie Forrest


2 Answers

u set set textLabel number of line 0

     cell.textLabel.numberOfLines=0;
     cell.textLabel.lineBreakMode=UILineBreakModeWordWrap; or NSLineBreakByWordWrapping;

hope it help you

like image 162
kirti Chavda Avatar answered Nov 12 '22 04:11

kirti Chavda


Set the "setNumberOfLines" property of the label to wrap the text to required number of lines. If you don't want the "..." at the end of the text if it is too long then use

cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; or NSLineBreakByWordWrapping for ios 6 or more

Try to set height and width of textlable and tableviewcell dynamicaly refer this link

like image 4
Harshal Chaudhari Avatar answered Nov 12 '22 06:11

Harshal Chaudhari