Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reloadData only on tableView visible cells

Is that possible? To reload only the cells that are visible in order to do it more efficient.

like image 620
Samui Avatar asked Feb 07 '11 15:02

Samui


People also ask

What is the use of tableView reloadData property?

Reloads the rows and sections of the table view.

How do I know if Iitableview has completed reloadData?

When [tableView reloadData] returns, the internal data structures behind the tableView have been updated. Therefore, when the method completes you can safely scroll to the bottom. I verified this in my own app.


2 Answers

That's how table views work by default. The UITableView class never loads cells until they're about to appear onscreen, even when you call reloadData.

like image 90
jlehr Avatar answered Oct 11 '22 13:10

jlehr


To reload visible cells of tableview in Swift 3.0:

guard let visibleRows = pTableView.indexPathsForVisibleRows else { return }

pTableView.beginUpdates()

pTableView.reloadRows(at: visibleRows, with: .none)

pTableView.endUpdates()
like image 29
Usman Nisar Avatar answered Oct 11 '22 13:10

Usman Nisar