编辑时 tableView 中没有 didSelectRowAtIndexPath()

No didSelectRowAtIndexPath() in tableView when editing

我想调用 didSelectRowAtIndexPath(),但是当我处于编辑模式时事件不会被触发。这是我的代码:

override func viewDidLoad() {
    tableView.delegate = self
    tableView.dataSource = self
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.tableView.deselectRowAtIndexPath(indexPath, animated:true)
    let data = fetchedResultsController.objectAtIndexPath(indexPath) as! NSManagedObject
...
}

@IBAction func updateButtonClicked(sender: AnyObject) {
    toggleEditing()
}

func toggleEditing() {
    if self.editing {
        super.setEditing(false, animated: true)
        self.title = "Sicherung"
    } else {
        super.setEditing(true, animated: true)
        let cancelBarButton = UIBarButtonItem(title: "Fertig", style: .Plain, target: self, action: "stopEdit:")
        navigationItem.rightBarButtonItem = cancelBarButton
        navigationItem.hidesBackButton = true
        self.title = "Sicherung bearbeiten"
    }
}

func stopEdit(sender: AnyObject) {
    super.setEditing(false, animated: true)
    let cancelBarButton = UIBarButtonItem(title: "Bearbeiten", style: .Plain, target: self, action: "toggleEditing")
    navigationItem.rightBarButtonItem = cancelBarButton
    navigationItem.hidesBackButton = false
}

didSelectRowAtIndexPath() 仅在 self.editing == false.

时调用

我做错了什么?

AFAICS,您的问题是,在您的 table 视图中,allowsSelectionDuringEditing 设置为 NO(或 false,如果您使用的是 Swift).