0

Is it possible to know if a certain text is being completely shown in the textLabel of a UITableViewCell?

I mean: is it possible to find out if the ellipsis (dot dot dot) had to be shown because the text was to long to fit in the textLabel?

I am thinking of showing the accesoryDetailButton to let the user see the whole text if it didn't fit.

vikingosegundo
  • 51,574
  • 14
  • 135
  • 174
ElPiter
  • 3,804
  • 9
  • 44
  • 74

2 Answers2

2

Check the size of the string like this -

CGSize textSize = [title sizeWithFont:titleFont 
                         constrainedToSize:textLabelSize 
                             lineBreakMode:NSLineBreakByTruncatingTail];

Compare the size with your tableViewCell textlabel frame size.

If greater then it is having ellipsis else not.

Hope it Helps !!!

arun.s
  • 1,528
  • 9
  • 12
0

i wrote a custom truncating class in this answer if you use it, it will return a bool that will tell you if it truncated for not

Community
  • 1
  • 1
Fonix
  • 11,049
  • 2
  • 43
  • 69