I am creating a static tableview to as my page will have a mixture of text and images in different rows.
Here is an example. This was created in obj c webView, but i want to use Swift and be native, no webview
Here is the code in my tableViewController:
import UIKit
class AdaptiveRowTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self .tableView.rowHeight = UITableViewAutomaticDimension
self .tableView.estimatedRowHeight = 44
}
override func viewDidAppear(animated: Bool ) {
tableView.reloadData()
}
}
I have set the row height to 0.
I have tested with a label and an image. The label works fine, but the image's row is not adjusting correctly.
Here is the result.
Any ideas on how to fix the image row height?
There is a nice apple video where you can find how to create adaptive cell height from minute 24.
You have to create constraints between the text and image and the cell and create relationships between them. Basically set a top and bottom constraint between text and cell and create a height relationship between text and image.