问题是当我第一次发射然后它需要高度(从顶部和底部)。但是当向上和向下滚动时。然后删除额外的高度。我无法理解为什么会出现这个问题。
控制器代码
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 15
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:SampleCell = tableView.dequeueReusableCell(withIdentifier: "SampleCell") as! SampleCell
if indexPath.row == 0 {
cell.labelDescription.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.f Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.f Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.f Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like "
} else {
cell.labelDescription.text = "skdfjksj gkfjg"
}
tableView.sizeToFit()
return cell
}
UIImage的约束
答案 0 :(得分:0)
将UITableViewAutomaticDimension
设为heightForRowAt
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
将numberOfLine
的{{1}}设置为 0
&安培;设置UILabel