【发布时间】:2013-07-22 04:16:47
【问题描述】:
我正在像这样设置我的自定义单元格的图像。
__weak CustomCell *weakcell = cell1;
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:postPictureLink]];
//it uses AFNetwork's UIImageView+AFNetworking extension
[cell1.postImageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
weakcell.postImageView.image = image;
//this method call changes cell height according to image size
[weakcell layoutSubviews];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
}];
那么我该如何实现
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
方法使它可以根据我的单元格的大小给出不同的高度?由于图像大小可以不同,不同的单元格有不同的高度。
【问题讨论】:
-
您是否只在单元格上设置图像?或者还有什么其他的吗?
-
你在哪里有这个代码?您应该将图像添加到数据源,然后您可以在 heightForRowAtIndexPath 中查询其大小。
标签: ios objective-c cocoa-touch