获取iPhone中正在编辑的单元格UITableView的文本值

获取iPhone中正在编辑的单元格UITableView的文本值,iphone,ios,uitableview,edit,Iphone,Ios,Uitableview,Edit,我有一个可编辑的UITableView 当用户删除单元格时,我希望获得单元格的文本值,并将其从字典中删除(我可以这样做) 但是,我不知道如何获取单元格值文本。还有,有没有其他类似于html5data xxx的方式可以读取和访问 谢谢。像这样的东西 ... UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; NSString *cellText = cell.textLabel.text; /* you may

我有一个可编辑的UITableView

当用户删除单元格时,我希望获得单元格的文本值,并将其从字典中删除(我可以这样做)

但是,我不知道如何获取单元格值文本。还有,有没有其他类似于html5
data xxx
的方式可以读取和访问

谢谢。

像这样的东西

...
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
/* you may need cell.detailTextLabel.text too */
...
一般来说,使用
indexPath
跟踪内容更容易,使用行索引访问字典或数组以删除删除的单元格内容。

类似的内容

...
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
/* you may need cell.detailTextLabel.text too */
...

一般来说,我认为使用
indexPath
跟踪内容更容易,并使用行索引访问字典或数组以删除删除的单元格内容。

committeeditingstyle:
方法中,在

if (editingStyle == UITableViewCellEditingStyleDelete)
{
// type in

NSString * cellText;

cellText = [NSString stringWithFormat:[@"%@",cell.textLabel.text]];
//this is going to store the cell's text in a NSString, you can do the same with an array, //just change it from an NSString to an array, or whatever you want to store the value.
}

这将在删除单元格后立即将文本设置为NSString。决定删除哪个单元格的代码不在这里,为此您需要处理
indexPath

提交方式:
方法中,在

if (editingStyle == UITableViewCellEditingStyleDelete)
{
// type in

NSString * cellText;

cellText = [NSString stringWithFormat:[@"%@",cell.textLabel.text]];
//this is going to store the cell's text in a NSString, you can do the same with an array, //just change it from an NSString to an array, or whatever you want to store the value.
}

这将在删除单元格后立即将文本设置为NSString。决定删除哪个单元格的代码不在这里,为此您需要处理
indexPath

这很好,谢谢,但是有没有办法隐藏detailTextLabel但仍有文本?请尝试使用[cell.detailTextLabel setHidden:YES]或将其alpha更改为0。这很好,谢谢,但是有没有办法隐藏detailTextLabel但仍有文本?尝试使用[cell.detailTextLabel setHidden:YES]或将其alpha更改为0