Iphone 在iOS中重新加载特定的UITableView单元格

Iphone 在iOS中重新加载特定的UITableView单元格,iphone,ios,uitableview,Iphone,Ios,Uitableview,我有一个UITableView。我想根据所做的选择更新表数据。现在我使用[mytable reloadData];我想知道是否有任何方法可以更新选定的特定单元格。我可以使用nsindepath或其他方法进行修改吗?有什么建议吗 谢谢。我想您正在寻找这种UITableView方法: - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 对于

我有一个
UITableView
。我想根据所做的选择更新表数据。现在我使用
[mytable reloadData]
;我想知道是否有任何方法可以更新选定的特定单元格。我可以使用nsindepath或其他方法进行修改吗?有什么建议吗


谢谢。

我想您正在寻找这种
UITableView
方法:

 - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

对于iOS 3.0及以上版本,您只需拨打:

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
例如,要重新加载第2节第3行和第3节第4行,必须执行以下操作:

// Build the two index paths
NSIndexPath* indexPath1 = [NSIndexPath indexPathForRow:3 inSection:2];
NSIndexPath* indexPath2 = [NSIndexPath indexPathForRow:4 inSection:3];
// Add them in an index path array
NSArray* indexArray = [NSArray arrayWithObjects:indexPath1, indexPath2, nil];
// Launch reload for the two index path
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];

还可以获取对UITableViewCell对象的引用并更改其标签等

UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.textLabel.text = @"Hey, I've changed!";

我不熟悉索引路径。你能告诉我细节吗?顾名思义,nsindepath包含一个索引。索引由行和节两部分组成。您可以使用[nsindepath indexPathForRow:(NSUInteger)instation:(NSUInteger)]创建一个;每个部分可以有多行。例如,在iPod MP3播放器中,每个字母都有一个部分。本节的每一部分都包含几个艺术家。我已经编辑了我的原始代码来告诉你怎么做。