Ja po prostu próbuje dodać UITextField w UITableViewCell po Tableview: commitEditingStyle: forRowAtIndexPath :. Na wkładce, chcę dodać UITextField nad istniejącym komórce.
I skonfigurować textField z czymś takim:
-(void) setUpIndexField {
inputField = [[UITextField alloc] init];
inputField.textAlignment = UITextAlignmentCenter;
inputField.borderStyle = UITextBorderStyleRoundedRect;
inputField.keyboardType = UIKeyboardTypeNamePhonePad;
inputField.delegate = self;
}
Następnie w commitEditingStyle, mam coś takiego jak:
- (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.
}
Gdy klikam na akcesor Insert (+), to textField rzeczywiście się koleś na ekranie, ale nie w pobliżu komórki, która jest kliknięcie. Zgaśnie w losowej część UIView, a nie rzeczywistej komórki dla indexPath w którym + został kliknięty.
Insight on gdzie poszło źle i jak mogę umieścić UITextField na komórce, gdzie + został kliknięty byłby idealny.













