Ios cellForRowAtIndexPath和sizeToFit在滚动时减少标签宽度

Ios cellForRowAtIndexPath和sizeToFit在滚动时减少标签宽度,ios,iphone,uitableview,Ios,Iphone,Uitableview,我在UITableViewCell中有一个标签为init的自定义单元格 在我的cellForRowAtIndexPath方法中,设置标签内容后,我调用标签上的sizeToFit以获得正确的宽度和高度,但当我在TableView中滚动时,每次滚动时,每个单元格上的标签宽度都会减小 有人需要帮忙吗 谢谢 我的自定义UITableViewCell My cellForRowAtIndexPath方法 通过删除sizeToFit并在cellForRowAtIndexPath中指定高度和宽度来解决确定问题

我在UITableViewCell中有一个标签为init的自定义单元格

在我的cellForRowAtIndexPath方法中,设置标签内容后,我调用标签上的sizeToFit以获得正确的宽度和高度,但当我在TableView中滚动时,每次滚动时,每个单元格上的标签宽度都会减小

有人需要帮忙吗

谢谢

我的自定义UITableViewCell

My cellForRowAtIndexPath方法


通过删除sizeToFit并在cellForRowAtIndexPath中指定高度和宽度来解决确定问题

cell.excuse_texte.text = excuse.excuse_texte;


NSString *str = excuse.excuse_texte;
UILabel *gettingSizeLabel = [[UILabel alloc] init];
gettingSizeLabel.font = [UIFont systemFontOfSize:17];
gettingSizeLabel.text = str;
gettingSizeLabel.numberOfLines = 0;
gettingSizeLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(260.0f, 9999.0f);

CGSize theSize = [gettingSizeLabel sizeThatFits:maximumLabelSize];
// on resize sans sizetofit
cell.excuse_texte.frame = CGRectMake(cell.excuse_texte.frame.origin.x, cell.excuse_texte.frame.origin.y, cell.excuse_texte.frame.size.width, theSize.height);
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

BBExcuse *excuse = [self.list objectAtIndex:indexPath.row];


static NSString *cellIdentifier = @"Cell";

// Similar to UITableViewCell, but
BBTableViewCell *cell = (BBTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
    cell = [[BBTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}


cell.excuse_texte.text = excuse.excuse_texte;
// @TODO problem here ?
[cell.excuse_texte sizeToFit];

cell.excuse_auteur.text = excuse.excuse_auteur;
cell.excuse_date.text = excuse.excuse_date;
cell.up.text = [NSString stringWithFormat:@"%@", excuse.up];


cell.img.frame = CGRectMake(20, CGRectGetMaxY(cell.excuse_texte.frame)+20/2, 20, 20);
cell.up.frame = CGRectMake(45, CGRectGetMaxY(cell.excuse_texte.frame)+20/2+2, 20, 20);

// setup up


return cell;
}
cell.excuse_texte.text = excuse.excuse_texte;


NSString *str = excuse.excuse_texte;
UILabel *gettingSizeLabel = [[UILabel alloc] init];
gettingSizeLabel.font = [UIFont systemFontOfSize:17];
gettingSizeLabel.text = str;
gettingSizeLabel.numberOfLines = 0;
gettingSizeLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(260.0f, 9999.0f);

CGSize theSize = [gettingSizeLabel sizeThatFits:maximumLabelSize];
// on resize sans sizetofit
cell.excuse_texte.frame = CGRectMake(cell.excuse_texte.frame.origin.x, cell.excuse_texte.frame.origin.y, cell.excuse_texte.frame.size.width, theSize.height);