Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load more don't working #192

Open
shin1412-zz opened this issue Dec 8, 2020 · 1 comment
Open

load more don't working #192

shin1412-zz opened this issue Dec 8, 2020 · 1 comment

Comments

@shin1412-zz
Copy link

shin1412-zz commented Dec 8, 2020

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
Copy link

fukemy commented Nov 19, 2021

this lib is dead, pls using MJRefresh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants