我在 UITableViewCell
中有一个 UILabel
。
我用这个字符串设置文本:
@"Tes blablabla\nTes blablabla\nTes blablabla\nTes blablabla\nTes blablabla\nTes blablabla\nTes blablabla"
它应该显示 7 行,对吧?但它没有。它只显示第一行。
我在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
[cell.lblComment setText:[commentDict objectForKey:@"comment"]];
[cell.lblComment sizeToFit];
这是怎么回事?我也将行数设置为 0..
最佳答案
您需要以编程方式添加第二行,或根据您采用的方法在 Storyboards 中设置它:
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
关于ios - UILabel 不调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24607256/