ios - imageWithContentsOfFile memory issue -
my project having image sharing functionality. in functionality app asks user library want share.
i wrote below code assign image, retrieved default library/custom library.
device default library
imgvwmediafile.image = [uiimage imagewithcgimage:[asset thumbnail]; //(alasset *)asset
custom library (images @ documents/image/user)
imgvwmediafile.image = [uiimage imagewithcontentsoffile:path]; //(nsstring*)path
app displyas images in collection view having custom cell.
when select app custom library images retrieves documents directory ,but imagewithcontentoffile cosuming around 90 100 mb memory.
in other case when select app default libray, not cosuming more 8 or 10 mb memory.
i tried diffrent code stack q/a custom library, still memory issue there.
-1- cgimageref iref = [[uiimage imagenamed:asset] cgimage] ; imgvwmediafile.image=[uiimage imagewithcgimage:iref]; iref=nil -2- nsdata *imagedata = [[nsdata alloc] initwithcontentsoffile:path]; imgvwmediafile.image=[uiimage imagewithdata:imagedata]; imagedata=nil -3- imgvwmediafile.image=[uiimage imagenamed:path];
so please guide me that, how can load images document dir ?
what best way load images document dir without increasing memory load ?
the problem yhe images have saved disk large, loading lots of the, display in collection takes lot of memory. use thumbnails built in library see different result.
ideally save folder of thumbnails in custom library , display those, then, when image selected, corresponding full size image use (this approach photo libraries use). alternatively can resize images on-the-fly, scrolling guaranteed suck.
Comments
Post a Comment