iphone - UICollectionView datasource not working as expected -


so i've ran unique problem. have uicollectionview works find, long there's @ least 2 objects in array i'm pulling from.

- (nsinteger) collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section {     nslog(@"allocating space %i photos in collectionview", [ccphotos sharedphotos].photos.count);     return [ccphotos sharedphotos].photos.count; }  // configure cells - (uicollectionviewcell*) collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {     uicollectionviewcell* cell = [collectionview dequeuereusablecellwithreuseidentifier: @"photocell" forindexpath: indexpath];      nslog(@"creating cell row %i", indexpath.row);      (uiview* view in cell.contentview.subviews)         [view removefromsuperview];      cell.layer.cornerradius = 20.0f;     cell.layer.maskstobounds = yes;      // add image cell     uiimageview* imageview = [[uiimageview alloc] initwithimage: [[ccphotos sharedphotos].photos objectatindex: indexpath.row]];      // size imageview , set content mode     imageview.frame = cell.contentview.frame;      // add imageview cell     [cell.contentview addsubview: imageview];       return cell; } 

numberofitemsinsection gets called , returns correct value, if it's less 2, cellforitematindexpath not called. ideas?

edit: forgot mention used own flow layout sets such:

 - (id) init {     if (self = [super init])     {         self.itemsize = cgsizemake(item_width, item_height);         self.scrolldirection = uicollectionviewscrolldirectionhorizontal;         self.sectioninset = uiedgeinsetsmake(0, (320 - item_width) / 2, 0, 0);         self.minimumlinespacing = 320 - item_width;       }      return self; } 

first,i'm sorry,my english poor!

did write collection's layout,datasource , delegate?

eg.

uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; flowlayout.itemsize = cgsizemake(91.0f, (screensize.height - topnavigationbarheight - 24.0f) / 3.0f); flowlayout.sectioninset = uiedgeinsetsmake(10.0f, 10.0f, 10.0f, 11.0f); flowlayout.minimuminteritemspacing = 10.0f; flowlayout.minimumlinespacing = 10.0f; self.stepcollectionview = [[uicollectionview alloc] initwithframe:cgrectmake(0, topnavigationbarheight, screensize.width, screensize.height - topnavigationbarheight) collectionviewlayout:flowlayout]; self.stepcollectionview.datasource = self; self.stepcollectionview.delegate = self; [self.stepcollectionview registerclass:[stepthumbnailcollectionviewcell class]             forcellwithreuseidentifier:itemidentifier]; [self.view addsubview:self.stepcollectionview];  

i hope helps.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -