实现方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *oneCell = [tableView cellForRowAtIndexPath: indexPath];
if (oneCell.accessoryType == UITableViewCellAccessoryNone) {
oneCell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
oneCell.accessoryType = UITableViewCellAccessoryNone;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
本文介绍了一种在UITableView中切换UITableViewCell选中状态的方法。当用户点击单元格时,通过检查当前单元格的accessoryType来改变其显示状态,实现从无标记到带选中标记的切换,并在再次点击时恢复原始状态。
2万+

被折叠的 条评论
为什么被折叠?



