Cody Winton
Cody Winton

Reputation: 2989

UITableViewCell detailTextLabel text disappear when cell textLabel is too long

When the text in my TableViewCell is really long, the detailTextLabel disappears. I know UILineBreakModeTailTruncation is deprecated with iOS 6, so I tried this:

cell.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;

That didn't work. Any suggestions?

EDIT:

The detailTextLabel is set to "Right Detail" in my Storyboard, which is UITableViewCellStyleValue1.

Upvotes: 2

Views: 1469

Answers (1)

rdelmar
rdelmar

Reputation: 104082

This seems to be the way the Value1 type of cell works. The text label apparently has no fixed size to keep it from obscuring the detail label. The easiest way to fix this is to make your own custom cell with 2 labels. Give the detail label a fixed size and a constraint to the right side of the cell, and give the text label a constraint to the left side and a spacing constraint to the detail label (but no fixed size).

Upvotes: 2

Related Questions