我很难弄清楚如何根据 UIImage
和 UIView
中的其他内容动态调整每个 cell
的大小。
这里有一张图片可以更好地理解:
灰色背景是cell
的contentView
。
顶部的白色是一个UIView
。
这是我下载图像的方式:-
内部cellForRowAtIndexPath
cell.bigImageView.file = (PFFile *)object[@"image"];
[cell.bigImageView loadInBackground:^(UIImage * _Nullable image, NSError * _Nullable error) {
}];
根据storyboard
中单元格的大小设置heightForRow
中单元格的高度
return 535.0f;
最佳答案
提供 tableView 的 estimatedRowHeight
和 rowHeight
作为
tableView.estimatedRowHeight = 100.0 // Your estimated height of the row
tableView.rowHeight = UITableViewAutomaticDimension;
同时设置您的 tableView
。
更新:
对于左上角的图像:通向 UIView、顶部、尾随按钮、宽度和高度 对于按钮:宽度、高度、顶部、尾部到标签
对于标签:宽度、高度、顶部、拖尾到 UIView
对于 Bottom Button:引导到 UIView,尾随到 Label,Bottom 到 contentView,宽度,高度
对于底部标签:拖到 UIView,底部到内容 View ,宽度,高度
对于 ImageView:引导到 UIView,尾随到 UIView,顶部到 ImageView 上方的任何项目,底部到“底部按钮”或“底部标签”。将其宽度设置为等于内容 View 。没有高度,将其内容 Hugging 属性设置为低。
关于ios - 如何在 UITableView 中使用 UIView 实现动态单元格高度和图像高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37541649/