Novarg
Novarg

Reputation: 7440

Selectable UITableViewCells when UITableView is in editing mode

The title says everything. I need to make selecting of the UITableViewCells possible when UITableView is in the editing mode. I don't think that code is necessary here, but in case it is:

-(void)turnEditingOn {
  [self.tableView setEditing:YES animated:YES];
  if (self.tableView.isEditing)
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(newItem)];
  else
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(turnEditingOn)];
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(turnEditingOn)];
  //the rest of the code is omitted
}

So I need to be able to make taps on the cells when it's in the editing mode, just like the Clock app when you are editing alarms.

Thank you

EDIT

Forgot to mention:

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

and

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

are not getting called in the editing mode

Upvotes: 3

Views: 773

Answers (1)

Eugene
Eugene

Reputation: 10045

- (void)viewDidLoad {
  [super viewDidLoad];
  self.tableView.allowsSelectionDuringEditing = YES;
}

Upvotes: 8

Related Questions