Objective c 从heightForRow访问UITableViewCell

Objective c 从heightForRow访问UITableViewCell,objective-c,cocoa-touch,uitableview,Objective C,Cocoa Touch,Uitableview,我有以下代码: - (CGFloat)tableView:(UITableView *)_tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; return cell.imageView.frame.size.height + 40; } 我想做的是

我有以下代码:

- (CGFloat)tableView:(UITableView *)_tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    return cell.imageView.frame.size.height + 40;

}

我想做的是以某种方式访问单元格的属性。我希望单元格的高度等于单元格图像视图中图像的高度。我认为这不起作用。

不要尝试访问手机。表的数据源或单元格以外的其他对象应该管理该图像。向该对象索要图像并测量其大小


将单元格视为数据容器会使模型、视图和控制器层变得混乱,可能会使更改变得更加困难。

Ok,因此我的图像将从JSON文件返回,并存储在NSDictionary中。我应该访问文件,获取图像,然后返回其大小吗?不,从字典中获取。对不起,这就是我的意思。谢谢