无法设置表格视图单元格的动态高度? [英] Not able to set the dynamic height of table view cell?

查看:102
本文介绍了无法设置表格视图单元格的动态高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设置表格视图单元格的动态高度时遇到问题。我使用以下代码对其进行设置,但实际上,现在单元格高度甚至增加了,都无法正常工作。

I am having the problem in setting the dynamic height for my table view cell.I have used the following code to set it, but it's not working in fact now the cell height has even increased.

请参见我在项目中添加的代码:

See this the code I have added in my project:

 override func viewDidLoad() {
super.viewDidLoad()

        tableview.rowHeight = UITableViewAutomaticDimension
        print(tableview.rowHeight)
        tableview.estimatedRowHeight = 120

}

这是表视图单元格内容约束的屏幕截图:

This the screenshot for the constraints of the table view cell contents:

请同时查看约束。在此先感谢:)

Please have a look at the constraints as well. Thanks in advance :)

推荐答案


  • 如果您所做的一切正确但仍然无法解决获得期望的输出意味着问题将受到约束。

    • If u have done everything correct and still u r unable the get desired output means the issue will be with constraints.

      我制作了一个简单的约束布局,使用此框架作为参考并重新约束你的细胞。

      I have made a simple constraint layout, use this skeleton as reference and re-constraint your cell.

      添加(W:20,H:20) [img]。

      Add (W:20, H:20) to [img].

      请确保将行数设置为0,并设置所有其他自动尺寸标注。

      Make sure you have set number of lines to 0, and all other automatic dimension stuff's.

      IB约束截图。

      这篇关于无法设置表格视图单元格的动态高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆