ios - SDWebImage Library - placeholder from URL -


i'm using sdwebimage download , cache images in uitableview asynchronously i'm having problems.

the scenario following: when cell created want load low quality blurred image (1-2kb) url, before real image comes in. after higher quality image downloaded, want show one. until now, i've tried these options, neither 1 seems work way expect:

1:

    sdwebimagemanager *manager = [sdwebimagemanager sharedmanager];     [manager downloadimagewithurl:[nsurl urlwithstring:lowqualityimageurl]                           options:0                          progress:^(nsinteger receivedsize, nsinteger expectedsize) {}                         completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, bool finished, nsurl *imageurl) {                              if (finished) {                                 cell.pictureview.image = image;                                 [manager downloadimagewithurl:[nsurl urlwithstring:highqualityimageurl]                                                       options:0                                                      progress:^(nsinteger receivedsize, nsinteger expectedsize) {}                                                     completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, bool finished, nsurl *imageurl) {                                                         if (image && finished) {                                                             [uiview transitionwithview:cell.pictureview                                                                               duration:0.1f                                                                                options:uiviewanimationoptiontransitioncrossdissolve                                                                             animations:^{                                                                                 cell.pictureview.image = image;                                                                             } completion:^(bool finished) {                                                                              }];                                                         }                                                     }];                             }                         }]; 

when code used, low quality image seems downloaded , showed before real image, if user scrolls fast in table, end wrong images cells (because of cell reusing - guess). - solution here?

2:

[cell.pictureview sd_setimagewithurl:[nsurl urlwithstring:lowqualityimageurl] placeholderimage:[uiimage new] options:sdwebimagerefreshcached completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, nsurl *imageurl) {             [cell.pictureview sd_setimagewithurl:[nsurl urlwithstring:highqualityimageurl] placeholderimage:image options:sdwebimagerefreshcached completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, nsurl *imageurl) {              }];     }]; 

this approach seems fix "wrong image cell" issue, of cells end showing corresponding blurred image istead of high quality image supposed show.

so, sum up, have advice how can achieve result want? (download low quality image -> show until high quality image downloaded -> replace high quality image)

le: when using 2nd approach see weird behaviour. console output:

  1. thumb set cell: 1

  2. real image set cell: 1

  3. thumb set cell: 2

  4. thumb set cell: 3

  5. thumb set cell: 0

  6. real image set cell: 0

it appears somehow, of downloads cancelled.

i ended using 2 uiimageviews, 1 each photo, overlapped. when real (big) image downloaded smoothly fade blurred one.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -