Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何访问自定义单元格文本字段值?_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 如何访问自定义单元格文本字段值?

Ios 如何访问自定义单元格文本字段值?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,嗨,我在tableview中有自定义单元格 我有六个部分和一行。每行都有文本字段 如何在保存操作中访问这些文本字段值 下面是我的cellForRowAtIndexPath代码 static NSString *CellIdentifier_result = @"ProfileFieldsCell"; iPhone_FieldCell = (FieldCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier

嗨,我在tableview中有自定义单元格

我有六个部分和一行。每行都有文本字段

如何在保存操作中访问这些文本字段值

下面是我的cellForRowAtIndexPath代码

    static NSString *CellIdentifier_result = @"ProfileFieldsCell";

    iPhone_FieldCell = (FieldCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier_result forIndexPath:indexPath];

    if(iPhone_FieldCell == nil)
    {
        iPhone_FieldCell = (FieldCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier_result];
    }

    iPhone_FieldCell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iph-menu-btn.png"]];
    iPhone_FieldCell.backgroundColor = [UIColor clearColor];
    iPhone_FieldCell.selectionStyle = UITableViewCellSelectionStyleNone;
    [iPhone_FieldCell.fieldName setText:[profileItems objectAtIndex:(long)indexPath.section]];
    iPhone_FieldCell.tag = 100+(long)indexPath.section;
    iPhone_FieldCell.fieldValue.delegate = self;

    return iPhone_FieldCell;

如果您的代码是它看起来的样子,那么在某个地方存在一个类
FieldCell:UITableViewCell
,那么您应该添加一个实例,比如调用它
FieldCell*cellTitle
并将其设置为与数据源中的单元格相等,如下所示

cellTitle = iPhone_FieldCell;
return iPhone_FieldCell;
如果返回多个单元格,则必须创建and If子句以防止
cellTitle
被分配到错误的单元格。要访问此单元格文本字段,只需执行以下操作:

cellTitle.fieldName

fieldName
是您试图保存的文本字段吗?保存操作是由单元格处理还是由控制器处理?fieldValue是textfield,save操作由控制器处理