I am setting a tableView but when running the app, the label's content is not stable, sometimes it shows full content, sometimes it doesn't. Looking for advise.
I attached the images for .xib setup and how tableView is displayed.
The code is my ViewController

@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UINib(nibName: "CustomTableViewCell", bundle: nil), forCellReuseIdentifier: "customCell")
tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableView.automaticDimension
tableView.dataSource = self
tableView.delegate = self
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) as? CustomTableViewCell else {
return UITableViewCell()
}
switch indexPath.row {
case 0:
cell.titleLabel.text = "Remaining Last Statement Balance"
cell.amountLabel.text = "$22198.45"
case 1:
cell.titleLabel.text = "Minimum Payment Due"
cell.amountLabel.text = "$2222198.45"
case 2:
cell.titleLabel.text = "Current Ballance"
cell.amountLabel.text = "$2198.45"
case 3:
cell.titleLabel.text = "Last Statement Balance"
cell.amountLabel.text = "$2198.45"
default:
break
}
return cell
}
}



I would recommend that you embed your labels in a horizontal stack view:
Stack view settings:
As you see... far fewer constraints to set.
You will also want to set the content Hugging and Compression Resistance priorities on the labels...
Title Label:
Amount Label:
Here is the source for the cell XIB:
Then your cell class:
and view controller class - slightly modified... I added a single-point red border around the table view so we can see its frame. In storyboard, I inset the table view 20-points on all 4 sides for clarity:
Looks like this: