嗨我在我的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