如果textlabel文本超过2行,我需要做什么才能获得省略号?我在下面的屏幕截图中指出了问题,然后是设置textLabel属性的代码。谢谢你的期待!
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//...
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.textLabel.numberOfLines = 2;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.text = [self.selectedSubject subject];
cell.detailTextLabel.text = @"May 21st, 2012";
return cell;
}
答案 0 :(得分:2)
您想要使用
cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation;
而不是
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
UILineBreakModeWordWrap仅在numberOfLines等于1时有效
答案 1 :(得分:1)
更改此
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
到
cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation;