iphone - 更新 Uitableview 中选定行的标题

标签 iphone objective-c ios

我正在使用以下代码获取 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/

相关文章:

ios - 在文件系统中创建一个随机文件夹并保存下载的文件iOS

iphone - TestFlight 找不到构建

iphone - 关于 UITableViewController Storyboard的建议

ios - iPhone 应用程序在某些设备上启动时崩溃,但在其他设备上运行

iphone - 如何重复调用UITableView?

ios - 如何在 iOS 中发起 POST 请求?

ios - 如何获取iOS设备屏幕的高度和宽度

ios - 将 Realm 中的单个键更新为模型数组中的模型数组

objective-c - 无法识别Objective-C类

ios - 检测用户何时按下取消 - telprompt - objective-c