来自searchDisplayController的performSegue没有调用prepareForSegue

时间:2015-03-30 20:43:36

标签: ios uitableview swift uisearchdisplaycontroller

我有UITableView个自定义单元格,在选中时会触发segue。没有问题。我还有一个搜索栏,可以正常排序。问题在显示searchDisplayController.searchResultsTableView时开始,我在其中选择一个单元格。 didSelectRowAtIndexPath毫无问题地发射。

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.performSegueWithIdentifier("details", sender: self)
}

然后毫不费力地触发performSegueWithIdentifier

override func performSegueWithIdentifier(identifier: String?, sender: AnyObject?) {
    println("Perform segue fired")
}

但是,永远不会调用prepareForSegue

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "doneSegue" {
        println("Done Segue")
    }

    if segue.identifier == "details" {
        if let destinationVC = segue.destinationViewController as? CoffeeDetailViewController {
            if let index = self.journalTable.indexPathForSelectedRow() {
                // Sets an object to hold the contents of the specific cell that was tapped
                let parametersForRow = coffeeEntry[index.row]
                let attributes: Dictionary = parametersForRow.entity.attributesByName as Dictionary
                let parameterDictionary: Dictionary = parametersForRow.dictionaryWithValuesForKeys(attributes.keys.array)
                println("Parameters: \(parametersForRow)")
                destinationVC.parameterDictionary = parameterDictionary
            }
        }
    }
}

我有一种感觉,我正在犯一个新手的错误,我只是没有看到什么。有什么想法吗?

编辑:我忘记了一条非常重要的信息。我正在使用searchDisplayController.searchResultsTableView的自定义单元格和故事板之外的笔尖。我在viewDidLoad

中注册了笔尖
override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.leftBarButtonItem?.title = "Back"

    var nib = UINib(nibName: "CoffeeTableViewCell", bundle: nil)
    searchDisplayController?.searchResultsTableView.registerNib(nib, forCellReuseIdentifier: cellIdentifier)
}

0 个答案:

没有答案