开发者

Editing a table like iPhone Mail

开发者 https://www.devze.com 2022-12-17 11:03 出处:网络
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 on

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 http://www.freeimagehosting.net/uploads/add199aa62.png


  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


@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.

0

精彩评论

暂无评论...
验证码 换一张
取 消