仅为一个tableView设置行高并忽略heightForRowAtIndexPath中的其他tableView?

Kri*_*man 1 uitableview ios heightforrowatindexpath swift

我有一个带有一个TableView的TableViewController,它有自动布局动态设置的行.

我已经向Controller添加了另一个TableView,用于菜单.它的行高需要设置为65.

问题是,在heightForRowAtIndexPath中.我知道如何为这个tableView菜单的行返回65.但我不知道如何让自动布局为其他tableView做的事情仍然存在.

有谁知道我怎么能做到这一点?

这是我的代码:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    if tableView is YALContextMenuTableView {
        return 65
    } else {

    }
}
Run Code Online (Sandbox Code Playgroud)

Glo*_*del 6

您可以通过以下super方式使用此方法的实现UITableViewController:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    if tableView is YALContextMenuTableView {
        return 65
    } else {
        return super.tableView(tableView, heightForRowAtIndexPath:indexPath)
    }
}
Run Code Online (Sandbox Code Playgroud)