ios - How to load UIImage to UICollectionView from an array of UIImage -


so after saving uiimage nsmutablearray imagepickercontroller want load images uicollectionview, cells not displaying though array isn't nil.

- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info   {     uiimage *image = [info objectforkey:uiimagepickercontrolleroriginalimage];     [_imgs addobject:image];     [picker dismissmodalviewcontrolleranimated:yes];     [self.collectionview reloaddata];      nslog(@"%d", [_imgs count]);      //[self viewdidload]; }  - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {      icon *icon = [collectionview dequeuereusablecellwithreuseidentifier:@"icon" forindexpath:indexpath];      uiimageview *recipeimageview = (uiimageview *)[icon viewwithtag:100];     recipeimageview.image = [uiimage imagenamed:[self.imgs objectatindex:indexpath.row]];      icon.image = (uiimage*)[self.imgs objectatindex:indexpath.row];     [icon.deletebutton addtarget:self action:@selector(delete:) forcontrolevents:uicontroleventtouchupinside];     return icon; }  @implementation icon - (id)initwithframe:(cgrect)frame {     self = [super initwithframe:frame];     if (self)     {         uiview *insetview = [[uiview alloc] initwithframe:cgrectinset(self.bounds, 300,  400)];         self.image = [[uiimage alloc]init];         uiimageview *img =[[uiimageview alloc]initwithimage:self.image];         [self.contentview addsubview:insetview];         [insetview addsubview:img];         self.layer.shouldrasterize = yes;     } } 

i created class called icon class wrap cells.

i think didn't set tag uiimageview object,so when trying access uiimageview using viewwithtag returns nothing.

uiimageview *img =[[uiimageview alloc]initwithimage:self.image]; img.tag = 100; [insetview addsubview:img]; self.layer.shouldrasterize = yes; 

i hope work.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -