【发布时间】:2018-01-30 09:04:50
【问题描述】:
我在 UITableViewCell 中有一个 UILabel。我已将它的约束设置为顶部、底部、前导、尾随。如果我给它 numberoflines 为 0,那么它不会占用任何空间。但是如果给它固定的行数,那么它会从顶部和底部占用额外的空间。请告诉我是什么问题?
UITableView 委托代码
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
约束给定为
UITableViewCell
的屏幕截图【问题讨论】:
-
显示您的代码,tableView 的数据源方法和单元格的设计代码
-
就像米兰说的,为你的问题提供更多信息
-
in
estimatedHeightForRowAt返回一个常量,例如:44,而不是UITableViewAutomaticDimension -
在estimateHeightForRowAt 方法中返回一些数字。
-
其他标签有多少行?
标签: ios swift uitableview autolayout