2015-12-30 33 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