UITextField in der UITableView-Zelle gibt null zurück

Ich habe meinen Kopf schon seit einiger Zeit gegen die Wand geschlagen. Jede Eingabe oder Richtung wird sehr geschätzt.

So ist das Ziel, ein Anmeldeformular aus Textfeldern in einer Tabelle zu erstellen. Diese Benutzerinformationen werden, sobald sie gesammelt wurden, an ein Array in einem separaten Ansichtscontroller weitergeleitet, damit sie in einer "Favoriten" -Liste gespeichert werden können.

So habe ich das Formular erstellt, das großartig aussieht, aber wenn ich die Formularergebnisse tröste, werden die Felder zurückgegeben (null). Ich habe die Seite für Antworten ausgewählt, kann aber nichts genaues sagen. Unten ist die cellForRowAtIndexPath: -Methode. Ich glaube, dass das Problem möglicherweise darin besteht, wo ich die textFields erstelle. Auch hier ist jede Eingabe willkommen!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
        NSArray *listData =[self.tableContents objectForKey:[self.sortedKeys objectAtIndex:[indexPath section]]];

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 
                                                                                                                                            reuseIdentifier:CellIdentifier] autorelease];

                textField = [[UITextField alloc] initWithFrame:CGRectMake(120, 13, 375, 30)];
                [textField retain];
        }

        textField.adjustsFontSizeToFitWidth = NO;
        textField.font = [UIFont fontWithName:@"Helvetica" size:14.0];
        textField.textColor = [UIColor darkGrayColor];
        textField.returnKeyType = UIReturnKeyDone;
        textField.backgroundColor = [UIColor clearColor];
        textField.autocorrectionType = UITextAutocorrectionTypeNo; 
        textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        textField.textAlignment = UITextAlignmentLeft;
        textField.clearButtonMode = UITextFieldViewModeNever;
        textField.delegate = self;

        if ([indexPath section] == 0) {
                switch (indexPath.row) {
                        case 0:
                                textField.placeholder = @"Optional";
                                textField.secureTextEntry = NO;
                                textField.keyboardType = UIKeyboardTypeDefault;
                                textField.tag = 0;
                                break;
                        case 1:
                                textField.placeholder = @"";
                                textField.secureTextEntry = NO;
                                textField.keyboardType = UIKeyboardTypeDefault;
                                textField.tag = 1;
                                break;
                        case 2:
                                textField.placeholder = @"";
                                textField.secureTextEntry = NO;
                                textField.keyboardType = UIKeyboardTypeDefault;
                                textField.tag = 2;
                                break;
                        case 3:
                                textField.placeholder = @"";
                                textField.secureTextEntry = YES;
                                textField.keyboardType = UIKeyboardTypeDefault;
                                textField.tag = 3;
                                break;
                        case 4:
                                textField.placeholder = @"Optional";
                                textField.secureTextEntry = NO;
                                textField.keyboardType = UIKeyboardTypeDefault;
                                textField.tag = 4;
                                break;
                        case 5:
                                textField.placeholder = @"Optional";
                                textField.secureTextEntry = NO;
                                textField.keyboardType = UIKeyboardTypeNumberPad;
                                textField.tag = 5;
                                break;
                }               
        }

        [textField setEnabled: YES];

        [cell addSubview:textField];

  cell.textLabel.text = [listData objectAtIndex:indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.editing = YES;

        return cell;
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage