【发布时间】:2018-04-09 18:48:05
【问题描述】:
我使用此代码为我的UITableView 使用动态高度单元格:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "QuestionsCell", for: indexPath) as! QuestionsCell
cell.label1.text = ""
cell.label2.text = ""
cell.label1.text = some text from array
cell.label2.text = some text from array
cell.label1.lineBreakMode = .byWordWrapping
cell.label1.numberOfLines = 0
cell.label1.sizeToFit()
return cell
}
然后,我在 Storyboard 中为每个元素(顶部、底部、前导和尾随)固定了所有约束。在 iPhone 上一切正常,但在 iPad 上,当我滚动 UITableView 时发生这种情况(动态标签高度):
【问题讨论】:
标签: ios swift uitableview