我正在使用以下代码获取 UiTableView 中的选定单元格
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// Mofify the cell here
}
当我更改单元格文本或颜色时,它不会对实际的 UitableView 进行任何更改
最佳答案
我建议您重新加载单元格。使用:
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:NO];
您应该跟踪选择了哪个单元格,并更新
中的单元格- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
我不知道为什么在您更改文本时文本没有为您更新
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但即使你让它工作,如果你将该单元格滚动到屏幕之外,它也会恢复。
关于iphone - 更新 Uitableview 中选定行的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8684328/