ios - TableView/Screen 的 AutoLayout UITableViewCell 高度倍数

标签 ios swift uitableview autolayout uikit

我有一个 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/

相关文章:

ios - SpriteKit,把一个进程放在另一个核心上?

iOS - 不同的 ViewControllers - 如何加载它们?

带有可以提取图像的 RSS 提要的 iOS 应用程序

ios - 将 Button 添加到常量可变 TableView

ios - 数组中特定元素的总和

ios - 快速通过编码按钮/功能发送数据

android - 有没有一种简单的方法可以将 Android 应用程序转换为 iPad、iPhone

iphone - 在 NSString 中将 NSData 显示为二进制

ios - 在 GRDB 和 Swift 3 中使用 rows.next() 编译错误

swift - 右键单击 NSTableView 行时如何添加(显示)上下文菜单?