嗨我在我的UILabel字段上使用sizetofit,它工作正常,当我加载tableview控制器,但然后开始切割的字母和包装到另一行时,当我上下滚动。下面是我的cellForRowAtIndexPath使用代码:UItableviewcontroller SizeToFit不工作在UILabel字段
- (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的屏幕截图的渊源加载:
这里滚动起来后,下您可以看到的描述有被切断
感谢您的帮助,您可以摹以解决这个问题。
干杯
卡森
显示'cellForRowAtIndexPath:'方法。 – rmaddy
@rmaddy见上面我现在正在显示完整的cellForRowAtIndexPath – Kitcc
在'sizeToFit'后面试试'setNeedDisplay' – anhtu