objective c - Adding photos from photo album into an app to display in a tableView - IOS -
i'm working on app allow me select photos photo album copy app viewing them in tableview. have view has add button , view button. when add button pressed uiimagepickercontroller displays showing me photos.
once select photo copy photo local app. once view button pressed tableview loaded showing of photos copied previously. i'm stuck @ portion @ moment. actual copying , storing of image future viewing.
any suggestions on how accomplish this? how creating plist , add file there?
thanks in advance!
t
if want save images uiimagepickercontroller
app, best way using document directory folder, save images document folder.
below post codes save image , retreive them.
-(void) saveimagenamed :(nsstring *) imagename andimage :(uiimage *) image{ nsdata *pngdata = uiimagepngrepresentation(image); nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentspath = [paths objectatindex:0]; //get docs directory nsstring *filepath = [documentspath stringbyappendingpathcomponent:imagename]; //add file name [pngdata writetofile:filepath atomically:yes]; }
and here how retreive image folder
-(uiimage *) getimagewithpath :(nsstring *) imagepath { nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); nsstring *documentspath = [paths objectatindex:0]; nsdata *pngdata = [nsdata datawithcontentsoffile:[documentspath stringbyappendingpathcomponent:imagepath]]; uiimage *image = [uiimage imagewithdata:pngdata]; return image; }
hope helps you.
Comments
Post a Comment