camera - UICollectionView not showing images from CameraImage - Objective C -


searched forum , not find suitable answer works. suspect wrong code. taking pictures camera , trying show them in uicollectionview. collectionview has cell uiimageview inside of it. when setting static image , background colour still don't see (not colour). code follows:

 #import "camerapageviewcontroller.h"   @interface camerapageviewcontroller ()  @end  @implementation camerapageviewcontroller  - (void)viewdidload {    [super viewdidload]; // additional setup after loading view. _imagelist = [[nsmutablearray alloc] init]; _collectionview.delegate = self; _collectionview.datasource = self; [_collectionview registerclass:[uicollectionviewcell class] forcellwithreuseidentifier:@"picturecell"]; }  - (void)didreceivememorywarning {     [super didreceivememorywarning];   // dispose of resources can recreated. }   - (ibaction)takephoto:(id)sender {  uiimagepickercontroller *imagepickcontroller=[[uiimagepickercontroller alloc]init]; imagepickcontroller.sourcetype=uiimagepickercontrollersourcetypecamera; imagepickcontroller.delegate=self; imagepickcontroller.allowsediting=true; [self presentviewcontroller:imagepickcontroller animated:yes completion:nil];  }  - (void)imagepickercontroller:(uiimagepickercontroller *)picker     didfinishpickingimage:(uiimage *)image               editinginfo:(nsdictionary *)editinginfo {    uiimage *chosenimage = editinginfo[uiimagepickercontrolleroriginalimage];  [_imagelist addobject:chosenimage];  [self dismissviewcontrolleranimated:yes completion:nil];   [_collectionview reloaddata];   } - (nsinteger)numberofsectionsincollectionview: (uicollectionview *)collectionview { return 1; }  - (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { return [self.imagelist count]; }   - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { static nsstring *identifier = @"picturecell"; uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath]; uiimageview *pictureview = (uiimageview *) [cell viewwithtag:110]; nsinteger rowvalue = indexpath.row; uiimage *currentimage = [_imagelist objectatindex:indexpath.row]; pictureview.image = currentimage; return cell;  }   @end 

i think u might missed setting layout collection view set , try

- (void)viewdidload   {    [super viewdidload];     //...other code    _imagelist = [[nsmutablearray alloc] init];     //set layout hear    uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; //default layout    [flowlayout setscrolldirection:uicollectionviewscrolldirectionvertical];    flowlayout.minimuminteritemspacing = 0.0f;    flowlayout.minimumlinespacing      = 0.33f; //set offset between items   _collectionview.showshorizontalscrollindicator = no;   _collectionview.showsverticalscrollindicator   = no;   [_collectionview setcollectionviewlayout:flowlayout];    _collectionview.delegate = self;   _collectionview.datasource = self;   [_collectionview registerclass:[uicollectionviewcell class] forcellwithreuseidentifier:@"picturecell"]; }    //implement delegate method return item size each cell  - (cgsize)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout*)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath  {     return cgsizemake(200.0f,300.0f); } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -