title: UiviewControllers inside UICollectionViewCell
body: <p>I have a UICollectionView inside a UIViewController.
  The collectionView holds an array of 8 identifiers of view controllers from the storyboard.
  Each view controller in the array inherited from the UIViewController that holds the collectionView.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  {
  return _contentPageRestorationIDs.count;
  }
  
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
  UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
  
  BaseContentViewController *contentViewController = (BaseContentViewController *)[self.storyboard instantiateViewControllerWithIdentifier:self.contentPageRestorationIDs[indexPath.row]];
  
  // Set any data needed by the VC here
  contentViewController.rootViewController = self;
  contentViewController.view.frame = cell.bounds;
  [cell addSubview:contentViewController.view];
  
  return cell;
  }
  </code></pre>
  
  <p>So my problem is that my collection view swipe performance is really slow.
  How can i  improve the UICollectionView's performance?
  Are my view controllers inside the cell are "killed" when they are not on display?</p>
  
  <p>Edit:</p>
  
  <p>after the advice here i have changed my array to holding a view controllers instead of identifiers nsstring.</p>
  
  <p>In the ViewDidLoad:</p>
  
  <pre><code>_collectionView.delegate=self;
  _collectionView.dataSource=self;
  PRzeroVC  *zeroVC    = [[PRzeroVC alloc]init];
  PRoneVC   *oneVC     = [[PRoneVC alloc]init];
  PRtwoVC   *twoVC     = [[PRtwoVC alloc]init];
  PRthreeVC *threeVC   = [[PRthreeVC alloc]init];
  PRfourVC  *fourVC    = [[PRfourVC alloc]init];
  PRfiveVC  *fiveVC    = [[PRfiveVC alloc]init];
  
  _base           = [[BaseContentViewController alloc]init];
  
  _pages = [[NSArray alloc]initWithObjects:zeroVC,oneVC,twoVC,threeVC,fourVC,fiveVC, nil];
  
  [_collectionView reloadData];
  
  
  
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
  UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
  
  cell.layer.shouldRasterize = YES;
  cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
  _base = (BaseContentViewController *)_pages[indexPath.row];
  
  _base.rootViewController = self;
  _base.view.frame = cell.bounds;
  [cell addSubview:_base.view];
  
  return cell;
  }
  </code></pre>
  
  <p>My cell is not displaying the view Any idea why?</p>