SWRevealViewController nib 单元不执行 segue

SWRevealViewController nib cell not performing segue

简而言之,我的应用程序中有一个幻灯片导航视图控制器,背面 table VC 和正面 table VC。后面的 selected 单元格 table VC 应该转到前面 table VC(嵌入导航 VC)。为了说明这一点,这里是隔离的预更改设置和代码,它可以正常工作:

这是我后面的简化工作代码 table VC 的 cellForRowAtIndexPath 方法:

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let navigationCell = tableView.dequeueReusableCellWithIdentifier("NavigationCell", forIndexPath: indexPath) as UITableViewCell
    return navigationCell
}

好的,进入有趣的部分。我想要的只是将上面显示的默认 UITableViewCell 替换为我在 Xib 文件中的自定义单元格之一。现在我将说明我修改了什么。首先,这是我的 NavigationCell.xib 文件中的 Xib 单元格。没什么特别的。

我的NavigationCellclass代码很简单

import UIKit

class NavigationCell: UITableViewCell {
    @IBOutlet var nameLabel: UILabel!
}

最后,我修改了我后面的代码 table VC 以注册 Xib 并使自定义单元格出队:

override func viewDidLoad() {
    super.viewDidLoad()
    let navigationCellNib = UINib(nibName: "NavigationCell", bundle: nil)
    tableView.registerNib(navigationCellNib, forCellReuseIdentifier: "NavigationCell")
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let navigationCell = tableView.dequeueReusableCellWithIdentifier("NavigationCell", forIndexPath: indexPath) as! NavigationCell
    return navigationCell
}

所有其他代码和规范保持不变。如该问题的第一个屏幕截图所示,新自定义单元格的故事板转场仍然来自 class SWRevealViewControllerSeguePushController。我只是将默认的 UITableViewCell 换成了我的自定义 Xib 单元格。

这个修改足以阻止 segue 的发生。通过此修改,在我构建 运行 后,当我滑出后 table VC 导航菜单和 select 我的自定义导航单元之一(正确显示)时,它不会触发任何 segue。有什么想法吗?

我是个白痴。我必须在 didSelectRowAtIndexPath 中以编程方式执行 segue。

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