didSelectRowAtIndexpath

didSelectRowAtIndexpath

本文介绍了编辑时tableView中没有didSelectRowAtIndexPath()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想呼叫didSelectRowAtIndexPath(),但是当我处于编辑模式时,不会触发该事件.这是我的代码:

I want to call didSelectRowAtIndexPath(), but the event won't be fired, when I'm in edit-mode. This is my code:

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,您的问题是,在表视图上,allowsSelectionDuringEditing设置为NO(或false,如果使用的是Swift) ).

AFAICS, you problem is that, on your table view, allowsSelectionDuringEditing is set to NO (or false, if you're using Swift).

这篇关于编辑时tableView中没有didSelectRowAtIndexPath()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 05:15