UITableView Custom Cell的行高不会更新,Swift iOS8

时间:2015-11-03 19:57:17

标签: swift uitableview ios8 custom-cell xcode6.4

我在iOS 8的Xcode 6.4中的故事板中创建了一个UITableView自定义单元。当我在Storyboard的Size Inspector enter image description here中更改行高时,App中我的UITableView的自定义单元格没有任何变化。

3 个答案:

答案 0 :(得分:5)

您可以在TableViewController

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

答案 1 :(得分:0)

在tableview控制器的这个方法中:

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

确保添加以下行:

cell.height = yourHeight

答案 2 :(得分:0)

您可以在故事板上的表格视图中添加表视图单元格原型并拖动原型单元格底部,您可以获得高度单元格所需的内容。