我正在像这样设置自定义单元格的图像。如何调整下载的图片的单元格高度async
__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中查询其大小。 – rdelmar