自动TableView单元格高度无法正常工作

时间:2018-08-01 08:08:33

标签: ios swift uitableview uitableviewautomaticdimension

enter image description here

我在情节提要中有一个tableView Cell,如上图所示。

我在控制器中定义了动态单元格高度所需的必需内容,例如:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    return UITableViewAutomaticDimension
}

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return 250
}

和在viewDidLoad()

self.tblView.rowHeight = UITableViewAutomaticDimension
self.tblView.estimatedRowHeight = 250

但是我得到这样的输出:

enter image description here

似乎这里有一些自动布局冲突,这就是为什么它发生或我可能丢失了某些东西。 实际上,此单元格中有很多元素,并且发布约束的所有屏幕快照都会有些冗长。如果有人可以告诉您解决方法,或者您是否需要约束图像,我会提出疑问。

PS: 如果有人来这里,我建议您阅读以下提到的答案,它将为您提供帮助:

0 个答案:

没有答案
相关问题