【发布时间】:2016-03-05 23:45:54
【问题描述】:
我已经定义了一个自定义 UITableViewCell,在 UITableViewController 中使用,它显示在我的表格中。问题是单元格保留了原始高度,作为默认的 UITableViewCell,而不是使用我在“大小检查器”->“表格视图单元格”->“行高”中指定的高度。
我的自定义单元格加载如下:
tableView.registerNib(UINib(nibName: "CustomTableViewCell", bundle: nil), forCellReuseIdentifier: "Cell")
然后在tableView函数中:
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomTableViewCell
cell.titleLabel?.text = "title text"
cell.detailTextLabel?.text = "detail text to go here"
我曾尝试如下手动设置高度,但这也不起作用:
cell.frame.size.height = 100.0
对于将单元格置于正确高度的正确方法有什么想法吗?
XCode 7.2.1,iOS 9
【问题讨论】:
标签: ios xcode uitableview swift2