UITableViewCellで画像を表示しています。私が画面に入っているとき、画像は表示されませんが、スクロールした後、たとえば画像が表示されているセルを元に戻します。問題は以下のとおりです。方法:UITableViewの画像セルが再利用されるまでセルが表示されない
私が使用しているコードはbtnUploadImageActionに
[tableView reloadData];
を追加
{
EMROUploadImageCell *cell = (EMROUploadImageCell *)[tableView dequeueReusableCellWithIdentifier:@"EMROUploadImageCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (![[dictInput valueForKey:@"image"]isEqualToString:@""])
{
cell.imageViewUploadImage.layer.borderWidth = 0.0;
cell.imageViewUploadImage.layer.cornerRadius = cell.imageViewUploadImage.frame.size.height/2;
cell.imageViewEdit.hidden = YES;
cell.imageViewUploadImage.clipsToBounds = YES;
if (isImageChanged)
{
NSData *data = [NSData dataWithContentsOfFile:[dictInput valueForKey:@"image"]];
UIImage *image = [UIImage imageWithData:data];
[cell.imageViewUploadImage setImage:image];
}
else
{
[cell.imageViewUploadImage sd_setImageWithURL:[NSURL URLWithString:[dictInput valueForKey:@"image"]]
placeholderImage:nil
options:SDWebImageRefreshCached];
}
}
else
{
cell.imageViewUploadImage.layer.borderWidth = 1.0f;
cell.imageViewUploadImage.layer.borderColor = [[UIColor lightGrayColor] CGColor];
cell.imageViewUploadImage.layer.cornerRadius = cell.imageViewUploadImage.frame.size.height/2;
cell.imageViewEdit.hidden = NO;
cell.imageViewEdit.clipsToBounds = YES;
cell.imageViewUploadImage.layer.masksToBounds = YES;
cell.imageViewUploadImage.clipsToBounds = YES;
[cell.imageViewUploadImage setNeedsDisplay];
[cell.imageViewUploadImage setNeedsLayout];
[cell.imageViewUploadImage layoutIfNeeded];
}
[cell.btnUploadImage addTarget:self action:@selector(btnUploadImageAction:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
'EMROUploadImageCell'と' sd_setImageWithURL'を表示します。 – shallowThought