Skip to content

load more don't working #192

@shin1412-zz

Description

@shin1412-zz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions