У меня растянутые изображения, отображаемые в TableViewCell.Мне нужно найти высоту и ширину изображения из изображения URL.Мне нужно найти соотношение сторон и разместить изображение в ячейке в соответствии с высотой динамической ячейки в Swift 4.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier.ManCell) as! ManCell
let image = self.posts[indexPath.row]["thumbnail_images"]["medium_large"]["url"].stringValue
let cleanString = removeHtmlTagsFromResponse(index: indexPath.row)
cell.nutriTitle.text = self.posts[indexPath.row]["title"].stringValue
print("labels: \(self.posts[indexPath.row]["title"].stringValue)")
cell.nutriDetail.text = cleanString
let lCount = calculateHeightOfLable(cellLabel: cell.nutriDetail)
print("string: \(cleanString)")
print("HeightCount: \(lCount)")
cell.nutriImage.sd_setImage(with: URL(string: image), placeholderImage: UIImage(named: "no_image"))
let heightContentSize = cell.bounds.height
print("HeightContentSize= ",heightContentSize)
return cell
}