views:

258

answers:

2

Hello,

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

+2  A: 

I haven't done this so all of the following comes straight from the documentation. This is how I would do it:

  1. Overwrite your view controller's 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.
  2. Use a custom UITableViewCell subclass for your cells.
  3. The key is to overwrite willTransitionToState: in your custom cell class. In this method, add a custom subview containing your radio button to the cell.
  4. Overwrite layoutSubviews to position the radio button and the rest of the cell's content in the cell.
  5. In 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.
Ole Begemann
Thank you I just + rep you. However I selected the other answer as that is exactly what I intent to do.
OscarMk
+2  A: 

Here is a good article about doing a Mail-style multiple selection:

http://cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html

St3fan
Thank you that tutorial is exactly what I need.
OscarMk