var pageNum = 10
var totalCount = 0
var isTotalData = false
var isDataRunning = false
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
let contentHeight = scrollView.contentSize.height
let height = scrollView.frame.height
if offsetY > (contentHeight - height) && isDataRunning == false {
isDataRunning = true
pageNum += 10
if pageNum > totalCount {
pageNum = totalCount
}
if isTotalData == false {
DispatchQueue.main.async {
self.tvMain.reloadSections(IndexSet(integer: 1), with: .none)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7, execute: {
self.fetchList()
})
}
}
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == list.count - 1 {
isDataRunning = false
}
}