mskw
mskw

Reputation: 10338

What are the effects of setting estimatedRowHeight in UITableView?

It seems that whatever I set in estimatedRowHeight, there isn't any visual differences. Performance wise, I'm not sure how setting a value such as 1 vs 100 makes any difference. The document just says setting a non-negative will give you a better performance, but doesn't elaborate more.

Upvotes: 2

Views: 377

Answers (1)

matt
matt

Reputation: 535304

In order to perform its full initial internal layout and thus paint the scroll indicators correctly, the table view must know the heights of all the rows (as well as any section headers etc.).

By supplying the estimatedRowHeight, you allow the table to perform a full initial internal layout knowing only the heights of the visible rows (because it uses the estimated height for all the other rows). For a table view with variable row heights, that's much, much faster.

(Of course there is no point to the estimatedRowHeight if the table view's rowHeight is in fact the height of every row.)

Upvotes: 1

Related Questions