Skip to content

Commit cada0f5

Browse files
committed
bugfix: cell重用时导致显示的图片错乱,或者crash
1 parent c47b638 commit cada0f5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Coding_iOS/Views/CCell/MessageMediaItemCCell.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ - (void)setCurObj:(NSObject *)curObj{
4444
[_imgView setSize:[self sizeWithImage:curImage originalWidth:kMessageCell_ContentWidth maxHeight:kScreen_Height/2]];
4545
}else if ([_curObj isKindOfClass:[HtmlMediaItem class]]){
4646
HtmlMediaItem *curMediaItem = (HtmlMediaItem *)_curObj;
47+
NSURL *currentImageURL = [curMediaItem.src urlImageWithCodePathResizeToView:_imgView];
4748
__weak typeof(self) weakSelf = self;
48-
[self.imgView sd_setImageWithURL:[curMediaItem.src urlImageWithCodePathResizeToView:_imgView] placeholderImage:kPlaceholderCodingSquareWidth(150.0) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
49-
if (image) {
49+
[self.imgView sd_setImageWithURL:currentImageURL placeholderImage:kPlaceholderCodingSquareWidth(150.0) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
50+
ESStrong(weakSelf, _self);
51+
if (image && [imageURL.absoluteString isEqualToString:currentImageURL.absoluteString]) {
5052
HtmlMediaItem *curBlockMediaItem = (HtmlMediaItem *)weakSelf.curObj;
5153
CGSize imageSize = image.size;
5254
if (![ImageSizeManager hasSrc:curBlockMediaItem.src]) {

0 commit comments

Comments
 (0)