ios - 如何在 UITableView 中使用 UIView 实现动态单元格高度和图像高度?

标签 ios objective-c uitableview uiview

我很难弄清楚如何根据 UIImageUIView 中的其他内容动态调整每个 cell 的大小。

这里有一张图片可以更好地理解:

灰色背景是cellcontentView

顶部的白色是一个UIView

enter image description here

这是我下载图像的方式:-

内部cellForRowAtIndexPath

cell.bigImageView.file = (PFFile *)object[@"image"];
[cell.bigImageView loadInBackground:^(UIImage * _Nullable image, NSError * _Nullable error) {

        }];

根据storyboard中单元格的大小设置heightForRow中单元格的高度

return 535.0f;

最佳答案

提供 tableView 的 estimatedRowHeightrowHeight 作为

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/

相关文章:

ios - 通过两个 ViewController 传输数据

objective-c - NSTableView 使用示例

ios - SKNode runAction 滞后 :completion: in recursive method

ios - 将 Game Center 好友及其分数加载到 UITableView

ios - 在屏幕/ View 中包含 Sprite 节点

ios - UIView 中的 MPMoviePlayerController

ios - 如何在tableview cell ios objective c中实现页面控制

ios - 识别选择了哪个tableviewcell并将值传递给另一个viewcontroller

ios - 可以让 Intel Edison 充当 iOS 的 Remote

objective-c - 方法中间的可选 block : safe?