title: How to make a programmatically push to a uicollectionview with custom cells
body: <p>I have two views in my app, the main view controller (<code>viewcontroller.m</code>) and a UICollectionView (<code>photoListViewController.m</code>), and something strange is happening, If a create a button on the main view controller, and create a PUSH via Storyboard, everything work's fine, but when i try to create the push programmatically i'm getting the following error:</p>
  
  <pre><code>*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /SourceCache/UIKit_Sim/UIKit-2935.137/UICollectionView.m:3241
  
  *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
  </code></pre>
  
  <p>I have created a custom class (photoListCell) to the cells, and connected everything via storyboard. </p>
  
  <pre><code>photoListCell.h 
  
  @property (weak, nonatomic) IBOutlet UIImageView *cellBackgroundImage;
  @property (weak, nonatomic) IBOutlet UILabel *cellDataLabel;
  @property (weak, nonatomic) IBOutlet UILabel *cellNameLabel;
  @property (weak, nonatomic) IBOutlet UIImageView *cellFooterImage;
  </code></pre>
  
  <p>This is how i'm creating the push on the Viewcontroller.m</p>
  
  <pre><code>-(void)goToPhotoList: {
  UICollectionViewFlowLayout *cvLayout = [[UICollectionViewFlowLayout alloc]init];
          [cvLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
          [cvLayout setItemSize:CGSizeMake(105, 105)];
          PhotoListViewController *photoVC = [[PhotoListViewController alloc]initWithCollectionViewLayout:cvLayout];
  
          photoVC.managedObjectContext = self.managedObjectContext; // Pass core data context
  
          [self.navigationController pushViewController:photoVC animated:NO]; }
  </code></pre>
  
  <p>And here is how i'm creating the cells in the collection view photoListViewController.m</p>
  
  <pre><code>-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *identifier = @"Cell";
  
      photoListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
  cell.cellBackgroundImage.image = [UIimage imageNamed:@"Something"];
  cell.cellFooterImage.alpha = 0.5;
  cell.cellDataLabel.text = @"Something";
  
  return cell; }
  </code></pre>
  
  <p>What should i do? Any help will be appreciated thanks!</p>