ios - Fetch a saved image and display -


i developing app in have stored images through imagepicker. want display same images in collectionview. got response path

path=assets/image/155/155_557b1259b8a51.jpg 

when add http://xyz.com.assets/image/155/155_557b1259b8a51.jpg shows error. how can images through path.please me out.

if know image path or name may implement this.

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{ uicollectionviewcell *cell = [[uicollectionviewcell alloc]initwithframe:cgrectmake(0, 0, 50.0, 50.0)]; cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cell" forindexpath:indexpath];  uiimageview *imageview = [[uiimageview alloc]initwithframe:cgrectmake(0, 0, 50.0, 50.0)];      [imageview setimage:[uiimage imagewithcontentsoffile:[[nsbundle mainbundle]pathforresource:@"your photo name here" oftype:@"png"]]];//if path main bundle //else // documentdirectory url nsstring *filepath = [[nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)objectatindex:0]stringbyappendingpathcomponent:filename]; [imageview setimage:[uiimage imagewithcontentsoffile:filepath]; }  [cell setbackgroundview:imageview]; nslog(@"%@",cell); nslog(@"index path = %ld",(long)indexpath.row); return cell; } 

you need set delegate , datasource of uicollectionview as

[yourcollectionviewobject setdelegate:self];// if need use didselect or like... [yourcollectionviewobject setdatasource:self]; 

and required datasource method returning count...

- (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section{ return count; } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -