Is it possible to get an out of the box UITableViewCell's labels to do multiple lines without subclassing? I tried the following settings but it's not working. The labels get positioned like you would expect with the expected spacing between labels but I only ever get a single line of text.
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
Use sizeToFit
after text
is set
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
cell.detailTextLabel.text = @"this string is too long to fit on one line";
[cell.detailTextLabel sizeToFit];
i can't add a comment to your post so i need to post a response:
try to change the cell.detailTextLabel frame too
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.