开发者

Prompting user for multiple selections in an iphone app

开发者 https://www.devze.com 2022-12-24 23:02 出处:网络
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'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:

  1. Provide a UITableView with all values the user can select.
  2. Keep a mutable array with one object (e.g. an NSNumber) per table row to store each row's selection state.
  3. 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.
0

精彩评论

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

关注公众号