预加载

作者: 授之以渔不如授之以鱼 | 来源:发表于2022-01-10 10:47 被阅读0次

    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()
    }
    

    }

    相关文章

      网友评论

          本文标题:预加载

          本文链接:https://www.haomeiwen.com/subject/xrdmcrtx.html