当我向下滚动到 UICollectionView
时,我想在 UICollectionView
中加载更多数据。我没有找到任何 swift 语言的库。谁能告诉我该怎么做?
问题1 -> 如何在向下滚动时加载更多数据
问题 2 -> 如果我能够在滚动到底部时获得更多数据,那么我应该如何添加相同的可变数组。所以它加载整个数据。
最佳答案
Swift 3 和 Swift 4:CollectionView 委托(delegate)方法
1) When scroll hit the bottom you can trigger
updateNextSet()
usingwillDisplay
function
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if indexPath.row == numberofitem.count - 1 { //numberofitem count
updateNextSet()
}
}
func updateNextSet(){
print("On Completetion")
//requests another set of data (20 more items) from the server.
}
2) Append your new data with existing array and reload collection view
collectionView.reloadData()
关于ios - uicollectionview 在底部滚动加载更多数据。 iOS swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37984327/