Multi Select Table View Cell and No Style Picker

I have a basic UITableView in which I want to include Mail.app style labels without having a select style. I have the following snippet:

#define UITableViewCellEditingStyleMultiSelect (3) - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleMultiSelect; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } 

However, this never displays the checkboxes when selected (although empty circles are displayed). Any ideas on how to fix this? I know that it uses undocumented functions, but I would really like to add support for check marks. My actual example uses a very customizable UITableViewCell , and I cannot enable the selection style!

sample table view

+3
source share
1 answer
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; if (self.tableView.isEditing) { cell.selectionStyle = UITableViewCellSelectionStyleBlue; } else { cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } -(UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleMultiSelect; } -(IBAction) switchEditing { [self.tableView setEditing:![self.tableView isEditing]]; [self.tableView reloadData]; // force reload to reset selection style } 
+6
source

Source: https://habr.com/ru/post/1394252/


All Articles