ios - uitableview 自动调整大小中图像和单元格的动态高度

标签 ios uitableview dynamic height autoresize

如何在 UITableView Autoresizing设置图像单元格动态高度 >。我在 Storyboard 中使用了 UI 自动调整大小。我正在从网络服务获取具有静态宽度和动态高度的图像,例如 Facebook。任何人都可以帮助我设置图像和单元格的动态高度。

最佳答案

您可以使用此方法动态更改 tableviewcell 的高度

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
 UIImage *img = [UIImage imageNamed:@"yourImage"];
 return img.size.height;
}

如果您在下载后有 imageurl,请使用下面的代码来更新高度

UIImage *img=[UIImage imageWithData:data];

[self.tableView beginUpdates]; [self.tableView endUpdates];

关于ios - uitableview 自动调整大小中图像和单元格的动态高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36880527/

相关文章:

iphone - 缓存 UIView 对象作为提高性能的一种方式

iphone - 是否可以在 iPhone 上录制/重放一组触摸事件以用于演示目的?

ios - Right Detail UITableViewCell 在 iPad 上不显示完整行

c# - 向 ExpandoObjects 添加方法

ios - 在iOS设备上更改HTML5音频标题

ios - 我如何创建一个与 "Cover vertical"相反的转换

ios - 重用 UITableViewCell 不起作用

ios - 滑动 UITableViewRowActions 时意外出现分隔线

swift - iOS8 Swift - 动态调整 tableview 单元格大小的问题

MySQL查询具有相同表名和列名的所有数据库