嗨,我在我的 UILabel 字段上使用 sizetofit,当我加载 tableview 控制器时它工作正常,但是当我上下滚动时开始切割字母并换行到另一行。这是我在 CellForRowAtIndexPath 中使用的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"subjectCell" forIndexPath:indexPath];
// Configure the cell...
// Load and display subject photo image
UIImageView *subjectImageView = (UIImageView *)[cell viewWithTag:200];
subjectImageView.image = [UIImage imageNamed:subjectImages[indexPath.row]];
// Load and display subject label
UILabel *subjectLabel = (UILabel *)[cell viewWithTag:201];
subjectLabel.text = [subjectItems objectAtIndex:indexPath.row];
[subjectLabel sizeToFit];// call this to fit size of the label according to text
return cell;
}
这是我最初加载的 tableviewcontroller 的屏幕截图:
在这里上下滚动后,您可以看到描述已被剪切
感谢您为解决此问题提供的任何帮助。
干杯
卡森