我的屏幕上有UITableView。它显示具有动态高度的节标题和行。
当我从Xcode8.3迁移到Xcode-9测试版时,这个设置有两个问题。
1头视图高度断裂的
2行的动态高度断裂
我把我的桌景设置为:


那我就有定制的牢房了



这是代码:
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return //dynamically calculated height according to msg text
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 30
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerHeight:CGFloat = tableView.sectionHeaderHeight
let headerView = HeaderView(frame: CGRect(x: 0, y: 0, width: tableView.width, height: headerHeight), withHeaderLable: "Date/Day of msg")
return headerView
}这在Xcode8.3中工作得很好,即使有多行消息,但是在Xcode9测试版中被破坏了:当我在Xcode9 beta中使用Swift3.2设置运行时:

当我在Swift4测试版中使用Xcode9设置运行时:

这种行为的原因是什么?
发布于 2017-06-22 11:22:16
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 30.0将其添加到您的viewDidLoad中,而不需要使用tableview委托方法estimatedHeightForRowAt。
https://stackoverflow.com/questions/44695865
复制相似问题