UITableView 自定义单元格的行高不更新,Swift iOS8

Row Height of UITableView Custom Cell doesn't update, Swift iOS8

我在 Xcode 6.4 in iOS 8 中的故事板中创建了一个 UITableView 自定义单元格。当我在故事板的大小检查器 enter image description here 中更改行高时,没有任何反应到应用程序中我的 UITableView 的自定义单元格。

您可以在 TableViewController:

中覆盖此方法来更新它
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 55
}

在你的表视图控制器的这个方法中:

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?

确保添加这一行:

cell.height = yourHeight

您可以在 Table View on Storyboard 中添加 Table View Cell Prototype 并将您的 Prototype Cell 拖到底部,您可以获得您想要的高度单元格。