【发布时间】:2025-12-27 02:45:16
【问题描述】:
使用此代码,我可以检查表中的多行。
但我想要的是一次只检查一行。这是我的代码:
- (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;
}
}
如果用户选择了不同的行,那么我希望旧行简单地自动取消选中。不知道该怎么做。
【问题讨论】:
-
对于那些回答正确的问题,您应该点击旁边的复选标记接受正确答案。
标签: ios xcode ios4 ios5 xcode4