1

I am trying to customize my UITableViewCell and am subclassing it and then overloading layoutSubviews as suggested in this thread:

Adjusting the positions of the labels in a UITableViewCell

I can get the width of my label to change this way, but I am unable to use the following to make the labels multi-line.

self.textLabel.numberOfLines = 2;
self.textLabel.lineBreakMode = UILineBreakModeWordWrap;

It appears to wordwrap but only show the first line centered vertically no matter how tall I make my cell. Any suggestions?

Community
  • 1
  • 1
Joey
  • 7,537
  • 12
  • 52
  • 104

2 Answers2

0

You just need to change the numberOfLines to 0. That should do the trick. Hopefully you found this out since it has been a year since you asked.

self.textLabel.numberOfLines = 0;
self.textLabel.lineBreakMode = UILineBreakModeWordWrap;
The iOSDev
  • 5,237
  • 7
  • 41
  • 78
Carlo Solano
  • 103
  • 7
0

Here is what I did to make this work. I consider it a workaround, though, as it really seems like it should be a 1-2 liner to be able to make the label in the UITableViewCell do multi-line.

Basically I subclassed the UITableViewCell and instead of overloading layoutSubviews I added a UILabel object and simply initialize it in the cellForRowAtIndexPath call that requests the cell. I don't use the textLabel that comes with UITableViewCell, although I do use the detailTextLabel (because I don't need to resize or alter this, yet).

Joey
  • 7,537
  • 12
  • 52
  • 104