Infinite Scroll on iOS with Swift

╄→尐↘猪︶ㄣ 提交于 2019-12-04 03:41:14

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

iOS' TableViewController takes care of that automatically. It asks its datasource only for the currently visible rows of the table (tableview.cellForRowAtIndexPath)

See the documentation for the UITableViewDatasource Protocol Reference

If you've got a "known dataset" (as in, you don't need to make a network call to fetch new data), then like @zizoft said, it'll be handled automatically in tableview.cellForRowAtIndexPath

If, however, you've got an "unknown dataset", (as in, you'll need to pull down data from the internet), you'll need to do something a bit more interesting - @ansible's suggestion would be appropriate in that case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!