【发布时间】:2017-01-19 11:50:40
【问题描述】:
信息:
我有Tableview,它的单元格带有Imageview。
在那个 Imageview 中,我从 imgURL 获取不同的图像...
我需要什么:
我需要根据从 imgURL 获取的图像高度的动态单元格高度。
注意:我没有使用自动布局,但我使用的是自动调整大小。
到目前为止我做了什么:
我在 ImageView 中使用了异步图像加载。 (#import "UIImageView+WebCache.h")
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
HomePostCell *cell=[tableView dequeueReusableCellWithIdentifier:strIdentifier];
if (cell==nil) {
cell = [[HomePostCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:strIdentifier];
}
[cell.imgMain sd_setImageWithURL:[NSURL URLWithString:strImgURL] placeholderImage:[UIImage imageNamed:@"postPlaceholder"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (!error) {
}];
return cell;
}
有什么解决办法吗?还是我们可以只使用自动布局来调整单元格大小?
提前谢谢..
【问题讨论】:
-
查看category
-
你能提供在我的情况下如何使用它的方法
-
该类别可以获取图像元数据,即 EXIF,其中包含有关图像分辨率的信息,因此您可以在下载图像之前获取图像大小,并提供给您的单元格大小。
-
这会很复杂,除非服务器提前发送大小。否则,您将不得不下载然后获取高度。之后,重新加载表格。
-
@Shubhank 图像始终具有 EXIF 和分辨率。
标签: ios objective-c uitableview uiimage autoresize