我正在像這樣設置自定義單元格的圖像。如何調整下載的圖片的單元格高度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