在我的应用程序中,我创建了表格视图并在表格视图中显示了图像和标签。我已经下载了图像并将图像高度设置为另一个类,并且我使用代表传递了图像高度值。在我的问题是,heightForRowAtIndexPath方法调用非常早,它再也不会调用。那么我如何设置单元高度取决于图像高度?如何在iPhone中动态设置单元高度?
//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]看起来很有希望? :http://stackoverflow.com/questions/460014/can-you-animate-a-height-change-on-a-uitableviewcell-when-selected – petert 2011-01-07 11:59:16