【发布时间】:2014-09-29 08:40:42
【问题描述】:
我有一个带有自定义单元格的 UITableView,其中也包含 UITableViews。我在获取这些单元格的高度时遇到问题。
我在 heightForRowAtIndexPath 中获取高度,为此我填充子 tableView(在单元格内)并调用 layoutIfNeeded。这给了我这个 tableView 的正确 contentSize。问题是单元格的整体大小是错误的并且不会改变。所以调用 cell.bounds.height 会返回一个不正确的值。
let cell:GroupCell = tableView.dequeueReusableCellWithIdentifier("GroupCell") as GroupCell
cell.configure(field as SingleField, delegate: self) // populates data
cell.tableView.layoutIfNeeded()
// cell.tableView.contentSize is correct
return cell.bounds.height // is wrong - bounds haven't changed
谁能指出我正确的方向?顺便说一句 - 我只针对 iOS8。
【问题讨论】:
标签: ios uitableview swift ios8