一次加载所有日期从firebase到tableview,但我想在我再次滚动到底部的时候加载10个项目,10个项目应加载到tableview,以下是我的代码
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let item = items[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "inciCell") as!
IncidentCell
cell.delegate = self
cell.setupCell(with: item, indexPath)
return cell
}
}
-
在委托方法中
cellForRowAtIndexPath
您可以检查诸如indexPath.row == items.count - 1
。
之类的东西 如果是真的,那么您从DB中获得10个项目,并将其
append
获得到您的项目。然后做
tableView.reloadData()
以使用10个新项目更新表视图。
您还可以在表视图的底部(tableFooterView
)中制作一些不错的旋转器。但这可能是下一步。
希望它有帮助。