ios - SDWebimage to load image in custom UITableViewCell, but when scroll the image load in other cell random -
i have insert in uitableview custom uitableviewcell sdwebimage project, , load image:
[cell.img_cell setimagewithurl:[self.url objectatindex:indexpath.row] placeholderimage:[uiimage imagenamed:nil] completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype) {...}];
but when scroll uitableview image in 1 cell, goes in cell example doens't have loaded yet image, , continue effect cell scroll, , if scroll tableview fast cell have loaded right image first, change random said above, how can fix it?
your table cells being reused scroll. means when image load finishes, cell might not "belong" original url anymore.
what should set image nil
in tableview:cellforrowatindexpath:
clear out reused images , then cancel pending requests in tableview:didenddisplayingcell:
, doesn't make efficient use of network bandwidth.
a better approach move image loading code table controller (using sdwebimagemanager
) , have wait proper cell once image has finished loading.
Comments
Post a Comment