title: scrollToItemAtIndexPath causing app to crash
body: <p>I'm trying to scroll my UICollectionView to the top via code. I am calling this method: </p>
  
  <pre><code>        [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
  </code></pre>
  
  <p>The crash: </p>
  
  <blockquote>
    <p>** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the collection view's data source did not return a valid cell from -collectionView:cellForItemAtIndexPath: for index path  {length = 2, path = 0 - 0}'</p>
  </blockquote>
  
  <p>Not too sure exactly how to fix this?</p>
  
  <p>Thanks! </p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is my collection view method - I'm loading three different type of cells if condition is met:</p>
  
  <pre><code>-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  
  {   static NSString *tableCellIdentifier = @"TableItemCell";
      static NSString *gridCellIdentifier = @"GridItemCell";
      UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  
      if (indexPath.item &lt; [self.tradeSearchArray count]){
  
          if (self.gridLayoutActive == NO){
  
              self.switchToTableLayout = NO;
              BBItemTableViewCell *tableItemCell = [collectionView dequeueReusableCellWithReuseIdentifier:tableCellIdentifier forIndexPath:indexPath];
  
              if ([self.tradeSearchArray count] &gt; 0){
  
                  self.toolBarButtomItem.title = [NSString stringWithFormat:@"%d Results", self.searchResult.searchResults];
  
                  self.switchToTableLayout = NO;
  
                  tableItemCell.gridView = NO;
                  tableItemCell.backgroundColor = [UIColor whiteColor];
                  tableItemCell.item = self.tradeSearchArray[indexPath.row];
  
              }
              return tableItemCell;
          }else
  
          {
  
              BBItemTableViewCell *gridItemCell= [collectionView dequeueReusableCellWithReuseIdentifier:gridCellIdentifier forIndexPath:indexPath];
  
              if ([self.tradeSearchArray count] &gt; 0){
  
                  self.toolBarButtomItem.title = [NSString stringWithFormat:@"%d Results", self.searchResult.searchResults];
                  self.switchToTableLayout = YES;
  
                  gridItemCell.gridView = YES;
                  gridItemCell.backgroundColor = [UIColor whiteColor];
                  gridItemCell.item = self.tradeSearchArray[indexPath.row];
  
              }
  
              return gridItemCell;
          }
      }else
      {
  
          BBLoaderCell *loaderCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LoaderCell" forIndexPath:indexPath];
          loaderCell.backgroundColor = [UIColor clearColor];
  
  
      if (self.maximumOffset - self.currentOffset &lt;= 1000.0) {
          [self loadMoreSearchResults];
  
          if (self.loadingMore){
              dispatch_async(dispatch_get_main_queue(), ^{
                  activityIndicator.hidden = NO;
                  [loaderCell.spinner startAnimating];
              });
          }
          else{
              dispatch_async(dispatch_get_main_queue(), ^{
                  activityIndicator.hidden = YES;
                  [loaderCell.spinner stopAnimating];
              });
          }
  
          return loaderCell;
      }
  }
  
      return nil;
  
  }
  </code></pre>