将UITableView连接到UIViewController

将UITableView连接到UIViewController,uitableview,swift,storyboard,Uitableview,Swift,Storyboard,我在脚本模式下尝试将UITableView与UIViewController2连接时遇到问题。我在UIViewController中创建了UITableView。当我单击任意单元格时,我希望它转到UIViewController2。此视图未连接到任何其他对象,而是在identity inspector中为其提供类和情节提要ID。当我试图调用那个类时,当我按下一个单元格时,它会变成一个黑屏,并且我在情节提要中的UIViewController2中没有任何内容是可见的。为什么呢?下面是一些我试过但没

我在脚本模式下尝试将UITableView与UIViewController2连接时遇到问题。我在UIViewController中创建了UITableView。当我单击任意单元格时,我希望它转到UIViewController2。此视图未连接到任何其他对象,而是在identity inspector中为其提供类和情节提要ID。当我试图调用那个类时,当我按下一个单元格时,它会变成一个黑屏,并且我在情节提要中的UIViewController2中没有任何内容是可见的。为什么呢?下面是一些我试过但没有用的代码。如果这不够清楚,请告诉我。谢谢大家!

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return featCatNames.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell

        cell.textLabel?.text = featCatNames[indexPath.row]
        return cell
    }

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        let mainStoryboard = UIStoryboard(name: "finalBusVC", bundle: NSBundle.mainBundle())
        let vc : UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("finalBusV") as UIViewController
        //let finaBus = self.storyboard?.instantiateViewControllerWithIdentifier("finalBusV") as finalBusVC
        //self.navigationController?.pushViewController(finalBusVC(), animated: true)
    }

为什么不在两个视图控制器之间建立一个通用的segue,然后可以调用performsguewithidentifiersomesegue来完成您的segue?我不确定您将如何实现这一点。我从来没有写过这样的东西?func tableview tableview:UITableView,didSelectRowAtIndexPath:nsindepath{self.performsguewithidentifiertablesegue,sender:self}是的!非常感谢,这看起来比我需要做的事情简单多了。一开始我没有把握,但我意识到我应该使用模态序列,而不是推