Uitableview 获取动态表视图中的文本字段值

Uitableview 获取动态表视图中的文本字段值,uitableview,tags,uitextfield,nsindexpath,Uitableview,Tags,Uitextfield,Nsindexpath,我有一个动态表视图,其中有5个原型单元格,每个单元格内有6个文本字段。我正在标记文本字段,但我很难理解如何从“textfielddidediting”中的所有字段中获取值。 在我的代码中,我有: -(void) textFieldDidEndEditing:(UITextField *)textField { NSMutableArray *cellOneContentSave = [[NSMutableArray alloc] init]; NSString *cellOneTexfieldO

我有一个动态表视图,其中有5个原型单元格,每个单元格内有6个文本字段。我正在标记文本字段,但我很难理解如何从“
textfielddidediting
”中的所有字段中获取值。 在我的代码中,我有:

-(void) textFieldDidEndEditing:(UITextField *)textField
{
NSMutableArray *cellOneContentSave = [[NSMutableArray alloc] init];
NSString *cellOneTexfieldOneTxt;
if (textField == [self.view viewWithTag:1503])
{
cellOneTexfield1Txt = textField.text;
[cellOneContentSave addObject:cellOneTexfieldOneTxt];  
}
问题1:但是!这只能从单元格1中的一个texfield中获取值…我是否应该为每个单元格和texfield使用开关

问题2:我说这是一个动态的表格视图,因此用户可以在输入提交编辑样式时按左侧显示的绿色+按钮插入新闻行(每个部分)…当他输入时,NewExFields的标记是否应该有不同的标记?。一方面我认为不是,因为它是新的texfields,但不同的indepaxth.row…但另一方面我不知道控制器是否需要新的标签

-(void) textFieldDidEndEditing:(UITextField *)textField
{
    // assuming your text field is embedded directly into the table view
    // cell and not into any other subview of the table cell
    UITableViewCell * parentView = (UITableViewCell *)[textField superview];

    if(parentView)
    {
        NSMutableArray *cellOneContentSave = [[NSMutableArray alloc] init];
        NSString *cellOneTexfieldOneTxt;

        NSArray * allSubviews = [parentView subviews];
        for(UIView * oneSubview in allSubviews)
        {
            // get only the text fields
            if([oneSubview isKindOfClass: [UITextField class]])
            {
                UITextField * oneTextField = (UITextField *) oneSubview;

                if(oneTextField.text)
                {
                    [cellOneContentSave addObject: oneTextField.text];
                } else {
                    // if nothing is in the text field, should
                    // we simply add the empty string to the array?
                    [cellOneContentSave addObject: @""];
                }
            }
        }
    }

    // don't forget to actually *DO* something with your mutable array
    // (and release it, in case you're not using ARC), before this method
    // returns.
}