我正在继承 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;
}