uicollectionview - How to add image into collection view cell from local library in ios? -


i have used uicollectionview display images. when click insert image button, photos in local library should added uicollectioncell using uiimagepicker. declared uiimageview in custom cell racollectionviewcell. in didfinishpickingmediawithinfo delegate method of uiimagepickerview whenever writing cell.imageview.image = chosenimage. getting error undeclared identifier "cell". please guide me how solve issue.

any appreciable, in advance!

here code:

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath             {                 static nsstring *cellid = @"cellid";                 racollectionviewcell *cell = [self.collectionview dequeuereusablecellwithreuseidentifier:cellid forindexpath:indexpath];                 [cell.imageview removefromsuperview];                 cell.imageview.frame = cell.bounds;                 cell.imageview.image = [uiimage imagenamed:[_photosarray objectatindex:indexpath.item]];                 cell.backgroundcolor = [uicolor lightgraycolor];                 [cell.contentview addsubview:cell.imageview];              uibutton *addbtn =[[uibutton alloc]init];                  addbtn.tag=indexpath.row;              deletebtn.frame = cgrectmake(100, 100, 19, 19);                            uiimage *img=[uiimage imagenamed:@"ic_add_photo.png"];                            [addbtn setimage:img forstate:uicontrolstatenormal];                            [addbtn addtarget:self action:@selector(addbtnaction) forcontrolevents:uicontroleventtouchupinside];                [cell.contentview addsubview:addbtn];             return cell;             }     -(void)addbtnaction      {          uialertcontroller *actionsheetcontroller = [[uialertcontroller alloc]init];              uialertaction *library = [uialertaction actionwithtitle:@"choose library" style:uialertactionstyledefault handler:^(uialertaction         * action)                                       {                                                 // library button tapped                                                    [self performselector:@selector(librarybtnaction) withobject:nil];                                            }];                  [actionsheetcontroller addaction:library];             actionsheetcontroller.view.tintcolor = [uicolor darkgraycolor];                   [self presentviewcontroller:actionsheetcontroller animated:yes completion:nil];             }              -(void)librarybtnaction             {                  uiimagepickercontroller *picker  = [[uiimagepickercontroller alloc]init];                  picker.delegate = self;                  picker.allowsediting = yes;                  picker.sourcetype = uiimagepickercontrollersourcetypephotolibrary;                  [self presentviewcontroller:picker animated:yes completion:nil];              } - (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info  {                   chosenimage = info[uiimagepickercontrollereditedimage];                  cell.imageview.image = chosenimage;                  [_collectionview reloaddata];                   [picker dismissviewcontrolleranimated:yes completion:null];              } 

  1. first problem in code , using "cell" object in didfinishpickingmediawithinfo , hell have defined that?

  2. how specify in image view of collection cell, show image picked library?

just use tag tracking things , in end of picking image load cell specific tag using indexpath.item , reload specific cell.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -