因此,当用户使用scrollViewDidScroll函数滚动到底部时,我尝试继续添加10行,而我从ScrollViewDidScroll得到响应"做某事"。我不知道每次调用scrollView时我应该如何向numberOfRowsInSection添加10行,以达到最大值aka allPosts。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
let allPosts = posts.count
return allPosts
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
let contentHeight = scrollView.contentSize.height
if offsetY > contentHeight - scrollView.frame.height {
//Here i want to add 10 to allPosts
print("do something")
if !fetchingMore {
beginBatchFetch()
}
}
}
func beginBatchFetch () {
fetchingMore = true
}
}