Thursday 15 September 2011

ios - Advice on thumbnail caching for UITableViewCell -



ios - Advice on thumbnail caching for UITableViewCell -

i'm using uitableview display list of images user has saved in app's documents directory. images large, more or less size , resolution of ipad's screen. tried using code generate thumbnails each time table view displayed, of course of study takes long this, if there lot of images saved:

nsstring *filepath = [_documentsdirectory stringbyappendingpathcomponent:basicfilename]; cgimagesourceref imagesource = cgimagesourcecreatewithurl((cfurlref)[nsurl fileurlwithpath:filepath], null); if (!imagesource) // if no image available, have folder { cell.imageview.image = [uiimage imagenamed:@"foldericon"]; } else { cfdictionaryref options = (__bridge cfdictionaryref)[nsdictionary dictionarywithobjectsandkeys: (id)kcfbooleantrue, (id)kcgimagesourcecreatethumbnailwithtransform, (id)kcfbooleantrue, (id)kcgimagesourcecreatethumbnailfromimageifabsent, (id)[nsnumber numberwithfloat:kdefaultcellheight], (id)kcgimagesourcethumbnailmaxpixelsize, nil]; cgimageref imgref = cgimagesourcecreatethumbnailatindex(imagesource, 0, options); uiimage *scaleddownimage = [uiimage imagewithcgimage:imgref]; cgimagerelease(imgref); cfrelease(imagesource); cell.imageview.image = scaleddownimage; }

to cut down delay, tried think think of way have thumbnails created , stored in cache first time user taps button table view appear. moved thumbnail creation didfinishlaunchingwithoptions in app delegate , have them saved app's cache file. going require more work create reliable , efficient solution, occurred me i'm missing in imageio can handle efficiently without me needing write lot of code. docs on imageio don't seem contain lot of detail. possible me create thumbnails once, , embed them in original png files images? or there way cache or store these thumbnails quick access @ time?

ios objective-c uitableview caching

No comments:

Post a Comment