eggswift / pull-to-refresh

#Busy Re-Building....# An easy way to use pull to refresh and infinite scrolling in Swift. Pod 'ESPullToRefresh'
MIT License
1.83k stars 251 forks source link

load more don't working #192

Open shin1412-zz opened 3 years ago

shin1412-zz commented 3 years ago

Hi, I want to loading all the data from API to the tableview at a time. But i just wanted to load 10 items at a time when i scroll to bottom again 10 items should load to the tableview, below is my code:

var model: [DataNotification] = []
var page = 1
func configureRefresh() {
        self.tableView.es.addPullToRefresh {[unowned self] in
            self.page = 1
            self.model.removeAll()
            self.initData()
            DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                self.tableView.reloadData()
                self.tableView.es.stopPullToRefresh()
            }
        }

        self.tableView.es.addInfiniteScrolling {[unowned self] in
            self.initData()
            self.page += 1
            DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                self.tableView.reloadData()
                self.tableView.es.stopLoadingMore()
                self.tableView.es.noticeNoMoreData()
            }
        }
    }
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return model.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = NotificationCell.loadCell(tableView) as? NotificationCell else {return UITableViewCell()}
        cell.selectionStyle = .none
        cell.setUp(data: model[indexPath.row])

        return cell
    }

thank for your help

fukemy commented 2 years ago

this lib is dead, pls using MJRefresh