【发布时间】:2011-06-05 05:48:02
【问题描述】:
在我的应用程序中,我创建了表格视图并在表格视图中显示了图像和标签。我已经下载了图像并将图像高度设置到另一个类中,并且我已经使用委托传递了图像高度值。在我的问题中,heightForRowAtIndexPath 方法被调用得非常早,并且它永远不会再次调用。那么我如何设置单元格高度取决于图像高度?
//appDelegate.imageHeight - 图片高度委托值。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(the height of the image is --------------------------%f, appDelegate.imageHeight);
In Console:
the height of the image is --------------------------0.000000
the height of the image is --------------------------0.000000
the height of the image is --------------------------0.000000
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(the height of the image is --------------------------%f, appDelegate.imageHeight);
In Console:
the height of the image is --------------------------98.567039
the height of the image is --------------------------300.000000
the height of the image is --------------------------232.288406
}
是否可以在 cellForRowAt 方法中调用 heightforRowAtIndexPath 方法。因为我设置了单元格框架的大小和高度取决于图像高度。那么如何设置单元格高度取决于图像高度?请指导我。
谢谢!
【问题讨论】:
-
我正在尝试向应用添加类似的行为;找到了这个帖子,这可能有解决方案? - 答案是调用 [tableView beginUpdates]; [tableView endUpdates] 看起来很有希望? :stackoverflow.com/questions/460014/…
标签: iphone uitableview height cell