如何根据从接口下载的图片的高度动态调整UITableViewCell's的高度?
我尝试使用tableView:cellForRowAtIndexPath:indexPath,但失败了。
仅供参考,我使用AFNetworking从api获取图像的url,并使用SDWebImage获取图像数据。
发布于 2015-06-30 21:20:18
从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。
https://stackoverflow.com/questions/31139361
复制相似问题