iphone - UICollectionView Cell nib not loading -


i'm using custom subclass of uicollectionviewflowlayout allows reordering of cells. source code here.

the issue running nib file created collection view not load despite registering , using correct identifier. here relevant code snippets.

this in view controller .m file:

- (void)loadview {     self.reorderlayout = [[lxreorderablecollectionviewflowlayout alloc] init];      self.collectionview = [[uicollectionview alloc] initwithframe:cgrectzero                                              collectionviewlayout:self.reorderlayout];      uinib *nib = [uinib nibwithnibname:@"catagoryviewcell" bundle:nil];     [self.collectionview registernib:nib forcellwithreuseidentifier:@"catagoryviewcellid"];      self.collectionview.datasource = self;     self.collectionview.delegate = self; }  - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {     catagory *c = [[[catagorystore defaultstore] allcatagories]                    objectatindex:[indexpath item]];      catagoryviewcell *cell = (catagoryviewcell *)[collectionview dequeuereusablecellwithreuseidentifier:@"catagoryviewcellid" forindexpath:indexpath];      [cell setcontroller:self];      [[cell namelabel] settext:c.title];     return cell; } 

these 2 places reference nib.

here cell nib: enter image description here

this looks in simulator , device:

enter image description here

i tried using similar code , original uicollectionviewflowlayout class , works fine. insight appreciated!

try "initwithframe" methods inside collectionviewcell.m

-(id)initwithframe:(cgrect)frame {  self = [super initwithframe:frame];  if (self) {     nsstring *cellnibname = @"yourcollectionviewcell";     nsarray *resultantnibs = [[nsbundle mainbundle] loadnibnamed:misventascellnibname owner:nil options:nil];      if ([resultantnibs count] < 1) {         return nil;     }      if (![[resultantnibs objectatindex:0] iskindofclass:[uicollectionviewcell class]]) {         return nil;     }     self = [resultantnibs objectatindex:0]; }  return self;     } 

then in class have de collection view add:

[collectionview registerclass:[yourcollectionviewcell class] forcellwithreuseidentifier:@"yourcollectionviewcell"]; 

and

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {  // setup cell identifier static nsstring *cellidentifier = @"yourcollectionviewcell";  yourcollectionviewcell *cell = (yourcollectionviewcell *)[cvarticles dequeuereusablecellwithreuseidentifier:cellidentifier forindexpath:indexpath]; } 

remember must insert in your.xib same cellidentifier using in identifier field of collection view!!!!!!!!


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -