Swift(某些)UITableViewDelegate方法不执行

Rub*_*Jr. 2 delegates uitableview ios swift ios8

我正在将我的一些代码从ObjC转换到Swift.到目前为止一直很好,但是我遇到了一些问题,我的一些UITableView的委托方法没有被调用.在ObjC中,我使用该tableView willDisplayCell forRowAtIndexPath方法将我的单元格设置为视图中的动画.虽然在Swift中向我建议了这个方法,但它永远不会被调用.同样的tableView willDisplayHeaderView forSection,和tableView editActionsForRowAtIndexPath.

我很确定我的课程设置正确:

class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
Run Code Online (Sandbox Code Playgroud)

并建议我的函数声明,所以这些都不正确.

func tableView(tableView: UITableView!, editActionsForRowAtIndexPath indexPath: NSIndexPath!) -> [AnyObject]! {
    ...
}

func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) {
    ...
}

etc.
Run Code Online (Sandbox Code Playgroud)

但是,当tableView数据显示出来时,这些单独的委托方法似乎永远不会运行.这是一个错误,还是我错过了什么?谢谢!

Ant*_*ton 7

您是否告诉了您的表格视图有关委托和数据源的信息?

self.tableView.delegate = self;
self.tableView.datasource = self;
Run Code Online (Sandbox Code Playgroud)