是否可以配置一个UITableView允许多选? [英] Is it possible to configure a UITableView to allow multiple-selection?

查看:165
本文介绍了是否可以配置一个UITableView允许多选?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iPhone,是否可以配置一个UITableView允许多选?



我试过覆盖 setSelected:animated:为每个UITableViewCell,但试图软化所需的行为是棘手的,因为很难分离真正的unselections UITableView认为我没有选择由于选择另一个单元格!



希望有人可以帮助你!



谢谢你,



$。

解决方案

这样做的最佳方法是每个选定行都有一个复选标记。
$ b

您可以通过将所选UITableViewCell实例上的accessoryType设置为UITableViewCelAccessoryCheckmark来实现。



要取消选择行,请将其设置回UITableViewCellAccessoryNone



要枚举选中的单元格/行(例如,单击按钮),只需遍历表的单元格寻找UITableViewCellAccessoryCheckmark。或者,在确实选择委托方法中,在表视图委托中管理一些NSSet等。


For the iPhone, is it possible to configure a UITableView such that it will allow multiple-selection?

I've tried overriding -setSelected:animated: for each UITableViewCell, but trying to fudge the required behavior is tricky as it's difficult to separate the real unselections from the ones where the UITableView thinks I've unselected due to selection of another cell!

Hope someone can help!

Thanks,

Nick.

解决方案

The best way to do this would be to a checkmark per selected row.

You can do that by setting the accessoryType on the selected UITableViewCell instances to UITableViewCelAccessoryCheckmark.

To deselect the row, set it back to UITableViewCellAccessoryNone.

To enumerate which cells/rows were selected (say, upon clicking a button), simply iterate over the cells of the table looking for UITableViewCellAccessoryCheckmark. Or, manage some NSSet or the like in your table view delegate in the "did select" delegate methods.

这篇关于是否可以配置一个UITableView允许多选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆