I would like to set the UITableView according to the height for all the content in the table view.
This is my storyboard.

The problem with this is the top and bottom image. ImageView is always static on the screen.

It is assumed that there should be 10 elements in the table view, but due to screen size limitations only 7 appears. I would like to show all 10 before the user can see the bottom ImageView. (btw, all 3 types, i.e. both image representations and tableview are in uiscrollview)
IDEAL

Some of the other limitations that I have to work with are that the number of elements in the table view is dynamic, which can be in any quantity, usually less than 10, which I will later choose from the api. And cell height is also dynamic depending on the content.
I just started with simple code
class ExampleViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var tableView: UITableView! var items: [String] = [ "Item 01", "Item 02", "Item 03", "Item 04", "Item 05", "Item 06", "Item 07", "Item 08", "Item 09", "Item 10"] override func viewDidLoad() { super.viewDidLoad() self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.items.count; } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell cell.textLabel?.text = self.items[indexPath.row] return cell } }
source share