-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Description
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
Labels
No labels