没有调用Swift UITableViewDelegate方法

Lor*_*ion 2 storyboard tableview ios swift

我创建了一个ViewControllerTableView使用它添加了一个storyboard.

我设置了类在StoryboardViewController我的NewsFeedViewController班.我将tableview出口的代表设置为self.

class NewsFeedViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var newsFeedTableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        newsFeedTableView.delegate = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell =
        newsFeedTableView.dequeueReusableCellWithIdentifier(
            "newsFeedIphoneCell", forIndexPath: indexPath)
            as! NewsFeedIphoneTableViewCell

        return cell
    }

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

    }

}
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,没有触发任何委托方法.我究竟做错了什么?

Mik*_*ash 7

您缺少数据源的分配.

尝试添加

newsFeedTableView.dataSource = self
Run Code Online (Sandbox Code Playgroud)

同样.