【发布时间】:2015-06-30 13:17:45
【问题描述】:
如何根据从 API 下载的图像的高度动态调整 UITableViewCell's 高度?
我尝试使用tableView:cellForRowAtIndexPath:indexPath,但失败了。
仅供参考,我使用 AFNetworking 从 api 获取图像的 url,我使用 SDWebImage 获取图像数据。
【问题讨论】:
标签: ios objective-c uitableview
如何根据从 API 下载的图像的高度动态调整 UITableViewCell's 高度?
我尝试使用tableView:cellForRowAtIndexPath:indexPath,但失败了。
仅供参考,我使用 AFNetworking 从 api 获取图像的 url,我使用 SDWebImage 获取图像数据。
【问题讨论】:
标签: ios objective-c uitableview
从heightForRowAtIndexPath 方法设置高度。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *image = (UIImage *)[tableImageDict objectForKey:
[NSString stringWithFormat:@"%i,%i",
indexPath.row,indexPath.section]];
if (image != nil)
{
return image.size.height; // you can set your size by taking from sdwebimage
}
else{
return 44.0;
}
}
查看与之相关的answer。
【讨论】: