tags:

views:

135

answers:

2

The iPhone Mail application has an edit button in the navigation bar. Tapping that button shows a delete button in the toolbar and shows checkbox controls in the table cells. Tapping one or more checkboxes then tapping the delete button causes the checked messages to be deleted.

How can I add similar functionality to my own code?

Here's a screenshot of the effect I'm looking for:

screenshot of spam folder with some messages checked

A: 
  1. UINavigationBar has a UINavigationItem with a leftBarButtonItem and a rightBarButtonItem. To set your edit button you init a bar button item with the style: UIBarButtonSystemItemEdit.

  2. Follow the delete button example here: http://dragonforged.com/devblog/?p=34

David Sowsy
A: 

@DavidSowsy's answer only shows how to draw a red button.

For those actually interested in selecting multiple rows in a UITableView, I have found 2 ways to do it:

  1. The easy way that involves undocumented APIs and will probably make your app crash in the next OS update.

  2. The proper one, that is a bit more work but works well and you won't have to think about it again.

For my project, I chose the latter.

Dimitris