我正在尝试更新UITableViewCell,当它被点击以获得一些反馈时:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[self.menuItems objectAtIndex:aPath.row] isEqualToString:@"AirPrint Order"]) {
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.textLabel.text=@"Generating Order Receipt";
NSArray *nsa = [[NSArray alloc] initWithObjects:indexPath, nil];
[tableView reloadRowsAtIndexPaths:nsa withRowAnimation:UITableViewRowAnimationNone];
}
}
Run Code Online (Sandbox Code Playgroud)
这个代码似乎什么都不做,即使在调试器中它确实使它在if语句中,但是单元格文本没有发生任何事情.
当您调用reloadRowsAtIndexPaths它时,实际上cellForRowAtIndexPath:再次调用并重新加载单元格,删除您应用于它的更改didSelectRowAtIndexPath.我建议你做的是:更新didSelectRowAtIndexPath方法中的数据并将其读入cellForRowAtIndexPath.
| 归档时间: |
|
| 查看次数: |
497 次 |
| 最近记录: |