Skip to content

Commit ff8afef

Browse files
author
Luc Dion
committed
Update UITableView example
1 parent 4d1c757 commit ff8afef

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Example/PinLayoutSample/UI/Examples/TableViewExample/TableViewExampleView.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TableViewExampleView: UIView {
3030
super.init(frame: .zero)
3131
backgroundColor = .white
3232

33+
tableView.estimatedRowHeight = 10
3334
tableView.dataSource = self
3435
tableView.delegate = self
3536
tableView.tableFooterView = UIView()
@@ -78,8 +79,8 @@ extension TableViewExampleView: UITableViewDataSource, UITableViewDelegate {
7879
}
7980

8081
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
81-
// Configure a MethodCell and ask its size.
82-
methodCellTemplate.configure(method: methods[indexPath.row])
83-
return methodCellTemplate.sizeThatFits(CGSize(width: tableView.bounds.width, height: .greatestFiniteMagnitude)).height
82+
// The UITableView will call the cell's sizeThatFit() method to compute the height.
83+
// WANRING: You must also set the UITableView.estimatedRowHeight for this to work.
84+
return UITableViewAutomaticDimension
8485
}
8586
}

0 commit comments

Comments
 (0)