I'm using a UITableView with cell style of UITableViewCellStyleValue1.
I'm want to have multiple lines in the detailTextLabel, is that possible? Or do I have to make a custom cell?
I'm using a UITableView with cell style of UITableViewCellStyleValue1.
I'm want to have multiple lines in the detailTextLabel, is that possible? Or do I have to make a custom cell?
At least on iOS 11 it works great just adding this line.
cell.detailTextLabel.numberOfLines = 2;
On SWIFT 4.0 and above:
cell.detailTextLabel?.numberOfLines = 0
Unless you never want to have more than 2 lines, do not set numberOfLines to 2 as advices in the comments because it's not an efficient way to code. It's not dynamic. The number of lines might be different base on your screen size, accessibility settings etc. Setting numberOfLines to 0, let the OS use as many lines necessary to display properly your text.