1

我正在继承 UITableViewCell。在我的自定义单元格的 xib 中,我有一个 UIImageView,它的框架为 (0, 0, 57, 57)。它的自动布局约束设置为顶部、左侧、宽度和高度。

首次渲染表格视图时,所有单元格看起来都很好。但是当我滚动时(并因此重用单元格), UIImageView 的框架将变为(15、0、57、57)。其他子视图似乎都没有受到影响。

在此处输入图像描述

UITableView 数据源:

- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    Content* content = [[[ContentManager sharedContentManager] allContent] objectAtIndex:indexPath.row];
    ContnetCell* cell = [tableView dequeueReusableCellWithIdentifier:kCellReuseIdentifier forIndexPath:indexPath];
    [cell loadWithContent:content];
    return cell;
}

细胞:

{
    [super prepareForReuse];
    self.imageView.image = nil;
}

-(void)loadWithContent:(Content*)content
{
    self.imageView.image = content.contentImage;
}
4

1 回答 1

4

是自定义单元格吧?如果您为自定义图像或标签使用与默认单元格中相同的属性名称(即imageViewtextLabeldetailTextLabel,可能会发生奇怪的事情。尝试重命名imageView为其他名称,看看是否可以解决问题。

于 2013-11-07T21:55:05.170 回答