为什么 UITableViewAutomaticDimension 不起作用? [英] why UITableViewAutomaticDimension not working?

查看:42
本文介绍了为什么 UITableViewAutomaticDimension 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多问题可以回答 UITableViewUITableViewCell 的动态高度.但是我做的时候觉得很奇怪.

Hi there is plenty of question answering the dynamic height for UITableViewCell of UITableView. However I find it weird when I did it.

这里有一些答案:

此处这里

通常这会回答单元格的动态高度

usually this would answer the dynamic height for cell

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableView.automaticDimension

但就我而言,我想知道这条线不会做任何事情.

but in my case I wonder this line wont do anything.

我的 UITableView 在点击 splitview 内的标签栏后被查看.这有帮助吗?

my UITableView is being viewed after clicking tabbar inside the splitview. Is this helpful?

也许我错过了一些东西.谁能帮我,我花了 2 个小时做傻事.

Maybe I'm Missing something. Could anyone help me I spent 2 hours doing silly.

这些是我对标题的约束,标题可能很长,但标签不是.

These are my constraint for title the title could be long but the label is not.

这是我的手机

推荐答案

为了使 UITableViewAutomaticDimension 正常工作,您必须设置所有与单元格容器视图相关的左、右、下和上约束.在您的情况下,您需要将缺少的底部空间添加到标题下标签的超级视图约束

In order to make UITableViewAutomaticDimension work you have to set all left, right, bottom, and top constraints relative to cell container view. In your case you will need to add the missing bottom space to superview constraint for label under the title

这篇关于为什么 UITableViewAutomaticDimension 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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