我有一个 tableViewCell,其中包含一个 imageSlider,它应该是屏幕高度的 40%。
自动布局有可能吗?将单元格添加到 tableView 后,已经为单元格计算了高度,因此为单元格高度添加的任何约束都将被忽略。
我可以实现 heightForRow 并返回正确的值,但我想知道我是否可以单独使用 AutoLayout 来实现这一点?
cell.imageSlider.heightAnchor.constraint(equalTo: tableView.heightAnchor, multiplier: 0.4)
最佳答案
向图像 slider 添加高度约束并在单元格中声明相应的 iboutlet。将其常量值设置为 view.bounds.size.height/60.0。让我知道它是否有效。
关于ios - TableView/Screen 的 AutoLayout UITableViewCell 高度倍数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38688481/