Or you can just do these steps:
1. Disable scrolling of the tableView.
2. Set height constraint to the tableView and a IBOutlet connected to it.
3. Before you reload the data, calculate the table height. heightConstraint.constant = (heightOfTheSingleTableViewCell) * numOfRows