ios - SDWebImage starts to load too late -


in cellforrowatindexpath, using following function inside dequeresuablecell update image in cell

    let imagensurl = nsurl(string: post.imageurl)     let placeholderimage = uiimage(named: "loadingplaceholder")!     postimageview.sd_setimagewithurl(imagensurl, placeholderimage: placeholderimage, options: [], progress: { (bytesent: int, byteexpectedtosend: int) in         // progress          }, completed: { (image: uiimage!, error: nserror!, imagecachetype: sdimagecachetype, url: nsurl!) in             if error != nil {                 print("error \(error.localizeddescription)")             } else {                 // image download complete             }     }) 

however, every time cell "just appear", see glimpse of placeholder image. seems sdwebimage sdk starts downloading image close when cell appears on screen. wondering if else experiencing or knows how fixed?

----update----

in response comments

i thought cellforrowatindexpath called way ahead of cell being displayed (2,3 cells?). willdisplaycell 1 displayed before cell shown. guess im wrong said made sense. was't scrolling fast , file 55kb. caching image works after image gets downloaded. want achieve image gets downloaded maybe 2,3 cells earlier ready in cache cell loaded.

what seeing network latency.

depending on cache state of url loading, sdwebimage downloading image remote server , depending on size , network type take few moments.

you aren't trying load image until cell dequeued, happens moments before cell displayed. want @ sdwebimageprefetcher. allow cache images @ earlier stage in app lifecycle , should (in cases) ensure images available locally prior showing cell eliminating network latency.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -