title: Collection View Text Field textFieldDidEndEditing when CollectionView Scrolled
body: <p>I have a Collection View that is a custom layout.  It contains text fields that users can update and it will save to an array.  The text fields take up the entire collection view cells , basically it looks like Microsoft Excel etc and scrolls horizontal and vertical.</p>
  
  <p>The problem is if you enter a number in a text field and scroll the collection view without hitting return, the cell is dequeued and the index path becomes null.</p>
  
  <p>I would like the text field to end editing if the collection view is scrolled.</p>
  
  <p>Here is the code I use for the textFieldDidEndEditing.  </p>
  
  <pre><code>- (void)textFieldDidEndEditing:(UITextField *)textField {
  UICollectionViewCell *selectedCell = (UICollectionViewCell *)[[textField superview] superview];
  UICollectionView *collectionViewForSelection = (UICollectionView *)[selectedCell superview];
  NSIndexPath *textFieldIndexPath = [collectionViewForSelection indexPathForCell:selectedCell];
  
  if (textFieldIndexPath != NULL) {
  [[_collectionArray objectAtIndex:textFieldIndexPath.section] replaceObjectAtIndex:textFieldIndexPath.row withObject:textField.text];
  [self saveArray];
  }
  }
  </code></pre>
  
  <p>I have tried without any luck and I didn't post any code from my attempts.</p>
  
  <p>Any suggestions on how to do this?</p>