iphone - UICollectionViewController multithread image loading -



iphone - UICollectionViewController multithread image loading -

i'm having problem loading images asyncronously between view controllers. have tableview controller opens collection view controller when click on row. when collection view opens, hangs while images downloaded internet.

i set next code in collectionview:cellforitematindexpath:, results in synchronous loading, , makes programme lag.

-(uicollectionviewcell *) collectionview:(uicollectionview *)cv cellforitematindexpath:(nsindexpath *)indexpath{ static nsstring *cellidentifier = @"collectioncell"; collectioncell *cell = [cv dequeuereusablecellwithreuseidentifier:cellidentifier forindexpath:indexpath]; nsdata *imagedata = [nsdata datawithcontentsofurl:[self.theimage objectatindex:indexpath.row]]; cell.itemimage.image = [uiimage imagewithdata:imagedata]; homecoming cell; }

my question is, where , how implement code such collection view loads empty cells while images downloading (and appear after download)?

i tried utilize grand central dispatch couldn't quite figure out. if help point me in right direction, i'd appreciate it.

for kind of lazy loading, use:

https://github.com/rs/sdwebimage

this solves of problems when want async load images in tables/collectionviews etc.

it supports caching of images downloaded , saves lot of headaches.

iphone objective-c

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -