UIImageView 在初始显示时在 tableview 单元格中对齐,但在之后不对齐

UIImageView alignment off in tableview cell on initial showing but not after

我创建了一个带有自定义 tableviewcells 的 tableview,其中我有一个 UIImageView 将保存图像。首次加载单元格时,图像对齐稍微向上太多并且有点向右。但是,如果我向下滚动以致无法看到单元格并向上滚动,它看起来是正确的。我不会以编程方式移动 UIImageView。我错过了什么?

这就是它的样子,初始加载在左侧,然后在右侧向下和向上滚动,这就是我希望它第一次看到的样子。底部是我的 xib 文件的截图。

我设置图像的 cellForRowAtIndexPath 中的代码如下所示:

[tableView registerNib:[UINib nibWithNibName:@"MainViewTableViewCell" bundle:nil] forCellReuseIdentifier:@"MainViewTableViewCell"];
MainViewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainViewTableViewCell"];
if (!cell) {
    cell = [[MainViewTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainViewTableViewCell"];
}

Post *post = self.maData[indexPath.row];

cell.titleLabel.text = post.title;
cell.titleLabel.adjustsFontSizeToFitWidth = YES;
cell.descriptionTextView.text = post.descriptionString;
cell.theContent = post.theContent;

UIImage *image = [_imageCache objectForKey:[@(indexPath.row) stringValue]];
if (image == nil) {
    image = [self imageWithImage:post.theImage scaledToSize:cell.imageView.frame.size];
    [_imageCache setObject:image forKey:[@(indexPath.row) stringValue]];
}
cell.imageView.image = image;
return cell;

使用这个工具https://github.com/Flipboard/FLEX调试你的UI,调试UIImageView的框架。也许在这种情况下它会对你有所帮助。