Básicamente estoy tratando de agregar un UITextField a una UITableViewCell sobre tableView: commitEditingStyle: forRowAtIndexPath :. En la inserción, quiero agregar un UITextField sobre la celda existente.
Configuro el textField con algo como esto:
-(void) setUpIndexField {
inputField = [[UITextField alloc] init];
inputField.textAlignment = UITextAlignmentCenter;
inputField.borderStyle = UITextBorderStyleRoundedRect;
inputField.keyboardType = UIKeyboardTypeNamePhonePad;
inputField.delegate = self;
}
Luego, en commitEditingStyle, tengo algo como:
- (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.
}
Cuando hago clic en el acceso de inserción (+), textField sí se despliega en la pantalla, pero no cerca de la celda que está haciendo clic en él. Se activa en una parte aleatoria de UIView, no en la celda real de indexPath en donde se hizo clic en el +.
La idea de dónde me equivoqué y cómo puedo colocar el UITextField en la celda donde se hizo clic en el + sería ideal.













