I wanna resize imageview'height after download image,but some wrong happened as first cell image when first load tableview;
then if I scroll table to make the cell be in visible again,it go to be normal as second image;
I don't known the size of image,can't get from server,how to fix it?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ShopingTableCell* cell = [tableView dequeueReusableCellWithIdentifier:@"shopingCell" forIndexPath:indexPath];
StoreDynamicsModel *model = storeArray[indexPath.row];
cell.contentLabel.text = model.name;
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.goods_img_url] placeholderImage:[UIImage imageNamed:@"defaultShort"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
dispatch_async(dispatch_get_main_queue(), ^{
cell.imgViewHeightConstraint.constant = image.size.height * ScreenWidth / image.size.width;
});
}];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
tableView.rowHeight = UITableViewAutomaticDimension;
tableView.estimatedRowHeight = 120.f;
return self.tableView.rowHeight;
}