Is it possible to configure a UITableView to allow multiple-selection?

For the iPhone, is it possible to configure a UITableView such that it will allow multiple-selection?

I've tried overriding -setSelected:animated: for each UITableViewCell, but trying to fudge the required behavior is tricky as it's difficult to separate the real unselections from the ones where the UITableView thinks I've unselected due to selection of another cell!

Hope someone can help!

Thanks,

Nick.

Answers


The best way to do this would be to a checkmark per selected row.

You can do that by setting the accessoryType on the selected UITableViewCell instances to UITableViewCelAccessoryCheckmark.

To deselect the row, set it back to UITableViewCellAccessoryNone.

To enumerate which cells/rows were selected (say, upon clicking a button), simply iterate over the cells of the table looking for UITableViewCellAccessoryCheckmark. Or, manage some NSSet or the like in your table view delegate in the "did select" delegate methods.


Following property should work fine if you are developing app for iOS5.0+

self.tableView.allowsMultipleSelection = YES;

Need Your Help

PHP Shopping - Purchase item

php security web-applications shopping spoof

Ok so i'm working on some coursework and my main goal is to create a deliberately vulnerable web application and a secure one to compare the differences between the two. I'm doing pretty good with ...

How to build a table with ng-repeat with mixed number of columns for row?

angularjs angularjs-ng-repeat

I really don't know how to succinctly describe what I'm trying to do so sorry for the bad title. But I have a table where I want to interlace different types of rows. I have one row that mirrors ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.