Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reload cell data in table view with Swift

how is it possible to reload data for a cell in my table view? I want to do a request to my Server and the server responses JSON. At the moment I implemented the request and the response handling and I can show the data in my cells. But I want that the server only responses maybe ten datasets. When I scroll to the end of the table view with my ten cells in the app I want to do the next request to my server and the server delivers the next ten datasets and so on. I work with Swift as the programming language.

THX!

like image 409
GRme Avatar asked Nov 03 '14 07:11

GRme


People also ask

How do you refresh a cell in Swift?

you can get Array of visible Cell by using TableView Function tableView. visibleRows() or You Can Get IndexPath of Visible Rows By tableView. indexPathsForVisibleRows() ! and then you can reload table by tableView. reloadData() Function!

How do I load a Collectionview cell?

Get the selected Superhero object ( selectedHero ) from the diffable data source using the index path. Append “★” to selectedHero 's name . Make a copy of the current diffable data source snapshot, so that we can modify it later. Modify the new copy of diffable data source snapshot by reloading selectedHero within it.

What does tableView reload data do?

reloadData()Reloads the rows and sections of the table view.


2 Answers

You can use self.tableView.reloadData() in order to reload your entire table or self.tableView.reloadRowsAtIndexPaths(paths, withRowAnimation: UITableViewRowAnimation.None) in order to reload a specific cell.

You can read more about the UITableView class here

like image 169
YogevSitton Avatar answered Oct 02 '22 23:10

YogevSitton


To reload visible cells of tableview in Swift 3.0

pTableView.beginUpdates()

pTableView.reloadRows(at: pMessagesTableView.indexPathsForVisibleRows!, with: .none)

pTableView.endUpdates()
like image 24
Usman Nisar Avatar answered Oct 02 '22 23:10

Usman Nisar