2015-12-30 25 views
0

当我使用方法加载图像时,下载图像后,直到我选择或滚动单元格时才显示,但如果我没有将placeholderImage设置为零,则效果很好。我不知道有什么问题。这里是我的代码:SDWebImage的一些问题

[cell.imageView sd_setImageWithURL:(my url) placeholderImage:nil]; 

与SDWebImage一些问题

+0

你可以尝试把这个方法放在main_queue上吗? –

+0

我用过SDWebImage,我看过他的代码,他用过(dispathch_main_aync_safe) – hmxxxhhh

+0

@CongTran我只试过了cell.imageView有问题 – hmxxxhhh

回答

0

这很奇怪,但你可以在您尝试[cell setNeedsLayout];设置图像以重新加载所有单元格视图。

我猜你有内部tableView:cellForRowAtIndexPath:

+0

你很好,当我使用这个方法时,它工作的很好:'[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@“http:// pic2。 ooopic.com/01/03/51/25b1OOOPIC19.jpg“] placeholderImage:nil completed:^(UIImage * image,NSError * error,SDImageCacheType cacheType,NSURL * imageURL){cell layoutSubviews]; }];' – hmxxxhhh

+0

但我仍然不知道为什么,如果placeholderImage不为零,即使没有代码[cell layoutSubviews],它也能正常工作。 – hmxxxhhh

-1

也许你可以使用另一种方法来做到这一点,作为一个例子:

[_theImageView sd_setImageWithURL:[NSURL URLWithString:_imageUrl]] 
+0

对不起,它有同样的问题。 – hmxxxhhh

+0

@hmxxxhhh哦,看起来很奇怪,请确定你的tableview是否有问题 – victor

0

完工块的所有调用来改变图像视图。

[myImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:IMG_PLACEHOLDER] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {}]; 

在您的项目中使用它并尝试。

+0

谢谢,我应该在代码里面填写'[cell layoutSubviews]'完成块。 – hmxxxhhh