Endless scrolling on iOS with Swift

I am new to iOS and I would like to know how to determine when a user scrolls and reaches the bottom of a UITableView so that I can load new data into a table.

I would also like to know where such a method should be implemented (a tableview class or a view controller in which this table view exists) Hurray!

+7
ios swift infinite-scroll
source share
3 answers

You can use -(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath to and check if the last cell in the TableView data source will be displayed.

+14
source share

iOS 'TableViewController automatically does this. It requests its data source only for currently visible table rows ( tableview.cellForRowAtIndexPath )

See the documentation for the UITableViewDatasource Protocol Reference

+4
source share

If you have a “known dataset" (like, for example, you do not need to make a network call to retrieve new data), then, as @zizoft said, it will be processed automatically in tableview.cellForRowAtIndexPath

If, however, you have an “unknown dataset” (like you, you will need to pull data from the Internet), you will need to do something more interesting - @ansible suggestion to be suitable in this case.

+3
source share

All Articles