Swift - 使用UITableView以编程方式切换视图

时间:2015-01-28 03:25:23

标签: ios uitableview swift xcode6

我无法使用UITableView切换到另一个视图控制器。我的代码如下所示。

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)

        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

        let dashViewController = storyBoard.instantiateViewControllerWithIdentifier("menuView") as DashViewController
        self.presentViewController(dashViewController, animated:true, completion:nil)

    }

enter image description here

我点击了我的一个单元格,它什么也没做!请指教。

1 个答案:

答案 0 :(得分:0)

我已经找到了答案,我忘了放UITableViewDelegate

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{

}

使用视图控制器分配tableview

enter image description here

相关问题