编辑时,`UITableView`不会调用didSelectRowAtIndexPath ??

ele*_*nse 45 iphone uitableview

我有一个UITableViewController用户应该能够编辑项目的地方.为了启用编辑我使用这个:

self.navigationItem.rightBarButtonItem = self.editButtonItem;
Run Code Online (Sandbox Code Playgroud)

对于不知道self.editButtonItem来自哪里的每个人,它都是由SDK预定义的.

所以,现在当我按下任何一个项目时,这个方法被称为:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
Run Code Online (Sandbox Code Playgroud)

但是当我点击编辑按钮并且编辑处于活动状态时,似乎没有调用此方法.

知道我错过了什么吗?

这是与编辑相关的其余代码:

// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return UITableViewCellEditingStyleNone;
}


- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return NO;
}
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助.

MCB

Dan*_*iel 124

您必须将UITableView的allowsSelectionDuringEditing属性设置为true.

参考:UITableView - allowsSelectionDuringEditing

  • 四年后,你仍在拯救生命! (4认同)
  • 魔术答案.. _superTableView.allowsSelectionDuringEditing = true; 和_superTableView.allowsSelection = true; 谢谢!! (2认同)
  • 即使10年后@thomax。 (2认同)