Kesong Xie
Kesong Xie

Reputation: 1396

Should cellForRowAt gets called only for visible cells after tableview.reloadData at the beginning?

When I called the tableView.reloadData from viewDidLoad, the cellForRowAt gets called for rows that are not visible at the beginning. For example, 10 cellForRowAt gets called while each cell has a row height approximately the screen height with autolayout constraint. But shouldn't the cellForRowAt those rows at the very bottom called at the beginning since they are not yet visible?

Upvotes: 0

Views: 116

Answers (1)

Kesong Xie
Kesong Xie

Reputation: 1396

It turns out I need to set the initial estimate row height for the tableView to a bigger value, something like

self.tableView.estimatedRowHeight = 400

Then only the cellForRowAt for the first two rows gets called

Upvotes: 1

Related Questions