如何标记多个 UITableViewCell 并对标记的单元格执行操作?
我想做的几乎与邮件应用程序所做的一样:当我选择“编辑”时,而不是通常的“删除”按钮,单选按钮出现在用户可以检查的一侧,然后用户可以单击一个按钮来采取对标记单元格的操作(任何类型的操作,不仅仅是删除)。有没有苹果示例代码可以做到这一点?任何人都可以提供一些关于如何执行此操作的代码或文档吗?谢谢。
-奥斯卡
I would like to do pretty much what the Mail Application does: that when I select Edit, instead of the usual Delete Button, Radio Buttons appear on the side that may be checked by the user, then the user may click on a Button to take an action on the marked cells(any kind of action not just delete). Is there any apple sample code that does this?, can anyone please provide some code or documentation on how to do this?. Thank you.
-Oscar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有这样做,所以以下所有内容都直接来自文档。我将这样做:
setEditing:animated:
方法,以在表格进入编辑模式时显示一个或多个按钮来执行批处理操作(就像 Mail.app 所做的那样) 。willTransitionToState:
。在此方法中,将包含单选按钮的自定义子视图添加到单元格中。layoutSubviews
以将单选按钮和单元格的其余内容放置在单元格中。tableView:didSelectRowAtIndexPath:
中,区分正常状态和编辑状态。如果表格处于编辑模式并且用户点击某个单元格,则将其标记为已选择(相应地修改单选按钮子视图)并保留所有标记单元格的记录。I haven't done this so all of the following comes straight from the documentation. This is how I would do it:
setEditing:animated:
method to display one or more buttons to execute your batch action (just like Mail.app does) when the table goes into editing mode.willTransitionToState:
in your custom cell class. In this method, add a custom subview containing your radio button to the cell.layoutSubviews
to position the radio button and the rest of the cell's content in the cell.tableView:didSelectRowAtIndexPath:
, differentiate between the normal and editing states. If the table is in editing mode and the user taps a cell, mark it as selected (modify your radio button subview accordingly) and keep a record of all marked cells.这是一篇关于进行邮件样式多项选择的好文章:
http://cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html
Here is a good article about doing a Mail-style multiple selection:
http://cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html