你认为这很容易.使用此代码,我可以检查表中的多行,但我想要的是一次只检查一行.如果用户选择不同的行,那么我希望旧行只是自动取消选中.不知道该怎么做.这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *theCell = [tableView cellForRowAtIndexPath:indexPath];
if (theCell.accessoryType == UITableViewCellAccessoryNone) {
theCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else if (theCell.accessoryType == UITableViewCellAccessoryCheckmark) {
theCell.accessoryType = UITableViewCellAccessoryNone;
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您提供的任何帮助!