I have a grouped UITableView and want to select some rows.
Hers some handy code I found to select multiple rows but for a ungrouped view.
—>
When I’m selecting a row it selects this row of every section.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}}
Any help ? Thanks in advance!
Have a look at – iPhone: How to allow multiple selection in tabelview for a custom cell?. If you just set the accessory type as you have done in your code, the accessories won’t be maintained when the cells are recycled (when the table is scrolled). Instead you should do something like the following-
This way, you can maintain which cells are selected.
HTH,
Akshay