title: iPhone: replacing a cell's view with UITextField
body: <p>I'm basically trying to add a UITextField to a UITableViewCell upon tableView:commitEditingStyle:forRowAtIndexPath:. On insert, I want to add a UITextField over the existing cell.</p>
  
  <p>I setup the textField with something like this:</p>
  
  <pre><code>-(void) setUpIndexField {
      inputField = [[UITextField alloc] init];
      inputField.textAlignment = UITextAlignmentCenter;
      inputField.borderStyle = UITextBorderStyleRoundedRect;    
      inputField.keyboardType = UIKeyboardTypeNamePhonePad;
      inputField.delegate = self;
   }
  </code></pre>
  
  <p>Then in commitEditingStyle, I have something such as:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tv
      commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
      forRowAtIndexPath:(NSIndexPath *)indexPath 
  {
      NSInteger row = [indexPath row];
      if (editingStyle == UITableViewCellEditingStyleInsert) {
      if (row == 0) {
          UITableViewCell *cell = [tv cellForRowAtIndexPath:indexPath];
          inputField.frame = [tv cellForRowAtIndexPath:indexPath].frame;
          [cell.contentView addSubview:inputField];
          [inputField becomeFirstResponder];
          return;
      }
  // more code etc.
  }
  </code></pre>
  
  <p>When I click on the Insert accessor (+), the textField does indeed get plopped onto the screen, but no where near the cell that's clicking it. It goes off into a random part of the UIView, not the actual cell for the indexPath at where the + was clicked.</p>
  
  <p>Insight on where I went wrong and how I can place the UITextField onto the cell where the + was clicked would be ideal.</p>