【发布时间】:2016-08-03 13:11:09
【问题描述】:
这是参考链接:
https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest
我在UICollectionView最后一个单元格中实现了加载更多,数据正在下载,下载完成后我想重新加载集合
collectionView.collectionViewLayout.invalidateLayout()
self.collectionView.reloadData()
let concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_async(concurrentQueue) {
DataManager.sharedInstance.homeRequest(Dictionary: params, onSuccess: { (dict) in
self.downloadPageIndex += 1
let response = HomeObject(dictionary: dict)
for (_,e) in (response.dataDict?.enumerate())!{
self.dataArray.append(e)
}
dispatch_async(dispatch_get_main_queue()) {
self.collectionView.reloadData()
self.collectionView.collectionViewLayout.invalidateLayout()
}
self.activityIndicatorCell.stopAnimating()
}, onError: { (error) in
self.activityIndicatorCell.stopAnimating()
})
喜欢这个collectionview reloadata
谁能帮帮我?
【问题讨论】:
-
这些行有什么问题?你有什么问题?
-
你能显示更多的负载吗?当您收到数据时会发生什么?
-
Collectionview 没有重新加载 ....
-
显示更多代码,你在哪里调用这些行?
-
您可能在后台线程上获取数据。然而,UI 更新必须发生在主线程上。尝试在主线程上调用 reload 方法。希望这会有所帮助。
标签: swift uicollectionviewcell uicollectionviewlayout