我是一名 iOS 开发新手。我想在我的 UITableViewCell
被选中时添加一个复选标记。选择另一行时,应删除复选标记。我该怎么做?
最佳答案
不要使用 [tableview reloadData];
//它是一把锤子。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
关于ios - ✔ 勾选 UITableViewCell 中选定的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7982944/