UITableView Pagination - Bottom Refresh to Load New Data in Swift

后端 未结 3 1717
感动是毒
感动是毒 2020-12-10 13:01

I am trying to implement loading data from my backend with pagination. I have seen this, but it loads all the data, all then time. Is this the right way or am I doing someth

3条回答
  •  感动是毒
    2020-12-10 13:39

    You should implement load more in tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath). When last cell loading is display it mean user scroll to bottom so this is time you need load more data.

    Maybe it looks like this:

    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    
        if !(indexPath.row + 1 < self.TotalRowsWithPages) {
            self.isLoading = true;
            self.getmoredata()
    
        }
    }
    

提交回复
热议问题