Swift - 表视图委托方法未从视图控制器类调用

时间:2015-04-16 18:39:53

标签: ios uitableview swift delegates

我在故事板中的视图控制器上放置了UITableView。我将表格视图的datasourcedelegate设置为self,并在视图控制器类声明中指定了UITableViewDelegateUITableViewDatasource。所有数据源功能都能正常工作。换句话说,当调用cellForRowAtIndexPath时,它执行正常。

问题是tableView的委托方法没有执行。我通过在

的开头放置一个断点来验证这一点
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat

我还注意到关键字optional被指定为上述委托方法的前缀:

optional func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat

但是,如果我将optional关键字添加到函数的开头,我会收到错误optional can only be applied to protocol members

我不知道为什么我的heightForRowAtIndexPath没有被调用。谁可以帮我这个事?提前谢谢。

0 个答案:

没有答案
相关问题