预加载

override func scrollViewDidScroll(_ scrollView: UIScrollView) {
let current = scrollView.contentOffset.y + scrollView.frame.size.height
let total = scrollView.contentSize.height
let ratio = current / total

let needRead = cellsPerPage * threshold + currentPage * cellsPerPage
let totalCells = cellsPerPage * (currentPage + 1)
let newThreshold = needRead / totalCells

if ratio >= newThreshold {
    currentPage += 1
    requestNewPage()
}

}

你可能感兴趣的:(预加载)