且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iOS中的CollectionView的页脚中添加加载指示器

更新时间:2023-12-05 16:45:10

我在 CCBottomRefreshControl 的帮助下找到了一个非常简单的解决方案
你需要就像简单的UIRefreshController一样对待它

I found one very easy solution with help of CCBottomRefreshControl You need to just treat it like simple UIRefreshController

let bottomRefreshController = UIRefreshControl()
bottomRefreshController.triggerVerticalOffset = 50
bottomRefreshController.addTarget(self, action: #selector(ViewController.refreshBottom), forControlEvents: .ValueChanged)

collectionView.bottomRefreshControl = bottomRefreshController

func refreshBottom() {
     //api call for loading more data
     loadMoreData() 
}

和您认为应该停止加载的地方

and where you think you should stop loader simply

collectionView.bottomRefreshControl.endRefreshing()