Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 基于UIImageView的UITableViewCell动态高度_Iphone_Uitableview_Uiimageview_Uiimage - Fatal编程技术网

Iphone 基于UIImageView的UITableViewCell动态高度

Iphone 基于UIImageView的UITableViewCell动态高度,iphone,uitableview,uiimageview,uiimage,Iphone,Uitableview,Uiimageview,Uiimage,我已将UITableView与大小为400的单元格分组。在里面我有UIImageView和来自NSURL的图像。如何制作这些图像以确定uitableviewcell高度?我怎样才能从下载的图像中得到真实的图像大小(至少是高度,在我的例子中它比宽度更重要) 它有点像9gag应用程序。大多数图像约占单元格的3/4,几乎占屏幕的1/2,但有些图像(如有趣的模因)有对话框且很长,应在两个屏幕上显示uitableviewcell(需要滚动查看整个图像)。您需要创建一个数组来保存下载的图像及其元数据。为了简

我已将UITableView与大小为400的单元格分组。在里面我有UIImageView和来自NSURL的图像。如何制作这些图像以确定uitableviewcell高度?我怎样才能从下载的图像中得到真实的图像大小(至少是高度,在我的例子中它比宽度更重要)


它有点像9gag应用程序。大多数图像约占单元格的3/4,几乎占屏幕的1/2,但有些图像(如有趣的模因)有对话框且很长,应在两个屏幕上显示uitableviewcell(需要滚动查看整个图像)。

您需要创建一个数组来保存下载的图像及其元数据。为了简单起见,此数组可以位于
UITableViewController

下载图像时,将其保存到
图像
数组中

然后,在
-tableView:heightForRowAtIndexPath:
方法中,查询此数组以获取保存图像的高度,例如

-(float)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
    return [self.images objectAtIndex:indexPath.row].size.height + 50;
}

这将使单元格比图像的高度高50px。请注意,要使其生效,您需要执行以下操作。

嘿,您找到解决方案了吗?我正在寻找同样的:(