I'm currently looking for a way to provide the user with being able to s开发者_运维百科elect multiple items from a collection of values.
I know this is done in the mail app whereby you can go into the edit mode of a folder and select multiple items by clicking on the circle on the left hand side.
What I'm unsure about is how this is achievable. Is anyone familiar with how to reproduce such functionality?
Thanks, Matt Delves
The easiest way is this:
- Provide a UITableView with all values the user can select.
- Keep a mutable array with one object (e.g. an NSNumber) per table row to store each row's selection state.
- In
tableView:didSelectRowAtIndexPath:
, toggle the selection state in your array for the tapped row and set the tapped cell's accessory type to checkmark or none, depending on the selection state.
精彩评论