ios - 在 Swift 中使用 UITableView 以编程方式切换 View

标签 ios uitableview swift xcode6

我无法使用 UITableView 切换到另一个 View Controller 。我的代码如下所示。

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

我点击了我的一个单元格,但它什么也没做。

最佳答案

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

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{

}

并为tableview分配view controller

enter image description here

关于ios - 在 Swift 中使用 UITableView 以编程方式切换 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28184105/

相关文章:

ios - UIRefreshControl 在 Xamarin iOS 上崩溃

ios - UILabel 文本截断与文本换行

ios - sharedApplication() 在 Today Extension 中无法快速工作

ios - 如何在使用 deleteRowsAtIndexPaths 删除行时删除节标题

ios - View Controller 之间的 Swift 传输数据保持为空

ios - 在 Swift 中发起异步 GET/POST 请求

arrays - 如何检查数组索引是否超出范围 SWIFT

ios - 如何在使用另一个 UISwitch 时更新一个 UISwitch

ios - Alamofire 不执行该 URL

ios - 当我快速呈现 UITableViewController 时,我的应用程序崩溃了