As you can see in the 1st Image . No text visible in UITableviewCell.
After I scroll it appears and resize the cell. I want to resize cell according to UIImage. I am fetching image from API using SDWebImage.
I am putting code I have done in UITableView Cell for row method .
cell.imgViewSlide.sd_setImage(with: URL(string:
self.arrSliderImage[indexPath.row]), placeholderImage: UIImage(named: "HomeSliderImage"), options: .continueInBackground) { (image, error, type, url) in
let screenBounds = UIScreen.main.bounds
let pixelWidth = Int((image?.size.width)!)
let pixelHeight = Int((image?.size.height)!)
let height = ((pixelHeight * Int(screenBounds.width)) / pixelWidth)
cell.heightImage.constant = CGFloat(integerLiteral: height)
}
I have applied plenty of solution but not working correctly.


First of all, as you are fetching the Images from dynamic URL using SDWebImage, Initially you need to set a static height for the image of your tableView Cell in the storyboard.
Define a constraint Outlet for this image height in your cell, and then you should define the height of the image according to the aspect Ratio.
Here
selfis the UITableViewCell reference andimgViewSlideHeightis the cell Image Height Constraint.