0
我使用包含标签和TextField的TabelViewCell创建了一个笔尖,然后我只用两行在TableView中加载此单元格。我想捕获一个项目的名称和它的价格,所以我更新了cellForRowAtIndexPath方法中的每个标签,因为我可以访问indexPath.row值。从单元格中的TextField中获取数据
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleCellIdentifier = @"AddBudgetItemCell";
SCAddBudgetItemCell *cell = (SCAddBudgetItemCell *)[tableView dequeueReusableCellWithIdentifier:simpleCellIdentifier];
if(cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:simpleCellIdentifier owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.dataTextField.delegate = self;
switch (indexPath.row)
{
case 0:
cell.titleLabel.text = @"Item";
break;
case 1:
cell.titleLabel.text = @"Price ¥";
break;
default:
break;
}
return cell;
}
但是我不知道我怎么能检索的文本字段的数据,因为我没有获得任何一种变量“细胞”我创造,也不是IndexPath.row值。