ios – UITableView复选框一次只有一行
2019年08月07日
作者:佚名
你会觉得这很容易.有了这个代码,我可以检查一个表中的多个行,但是我想要的是只能一次检查一行.如果用户选择不同的行,那么我希望旧行自动取消选中.不知道该怎么做这是我的代码:
- (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; } }
感谢任何帮助,你可以借出!
解决方法
最好的方法是在cellForRowAtIndexPath中设置附件类型,并使用didSelectRowAtIndexPath记录应选择哪个路径,然后调用reloadData.
以上是来客网为你收集整理的ios – UITableView复选框一次只有一行全部内容,希望文章能够帮你解决ios – UITableView复选框一次只有一行所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。