ios - UITableViewCell 没有扩展以适应 UILabel 的高度,我做错了什么?

标签 ios swift uitableview

我想要的是我的 UITableViewCell 根据内部 UILabel 的高度扩展/收缩。

我已经尝试了几乎所有我能找到的解决方案,但都没有用。也许我有一些阻止它的设置。

这是 UITableViewCell 设置的屏幕截图:

enter image description here

对于里面的UILabelLines设置为0Line Break设置为Word Wrap

在显示表格 View 的 UIViewController 中,我在 viewDidLoad() 中进行了设置:

tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 44
tableView.reloadData()

cellForRowAt 中,在我正在执行的单元格出列之后(instructionText 是 UILabel):

cell.instructionText.numberOfLines = 0

我在许多教程中都看到过它并且有效,为什么不对这些单元格使用呢?出来的内容是这样的:

enter image description here

这让我发疯!感谢您的帮助!

编辑:这是 UILabel 设置:

enter image description here

最佳答案

请检查您的标签限制

enter image description here

关于ios - UITableViewCell 没有扩展以适应 UILabel 的高度,我做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55701638/

相关文章:

ios - 选择 estimatedHeight 与 rowHeight 不同的项目时,iOS8 中的 UITableView 错误

iphone - iphone 应用程序开发的所有初学者都应该注意什么?

ios - 如何使用代码在模拟器上模拟不良的互联网连接

ios - 将 UITableView 与 Storyboard一起使用,但使用单独的数据源

iphone - 在 Swift 中使用分页将 subview 添加到 UIScrollview

swift - 如何在indexPath处的cellForRow中使用多个获取请求结果数组

ios - 具有不同功能的独特 UITableViewCell

ios - Apple In App Purchase Auto Renewal Subscriptions 付款未扣除,但 latest_receipt_info 中的 expires_date 已增加

ios - UIView 作为 subview 方向框架问题

swift - 几秒钟后添加一个 subview