【发布时间】:2019-02-06 18:39:53
【问题描述】:
我问的问题和here一样 我不明白如何实施解决方案。 我已经尝试了以下
fileprivate func fetchPhotos(indexSet: IndexSet) {
let allPhotos = PHAsset.fetchAssets(with: .image, options: assetsFetchOptions())
DispatchQueue.global(qos: .background).async {
allPhotos.enumerateObjects(at: indexSet, options: NSEnumerationOptions.concurrent, using: { (asset, count, stop) in
let imageManager = PHImageManager.default()
let targetSize = CGSize(width: 200, height: 200)
let options = PHImageRequestOptions()
options.isSynchronous = true
imageManager.requestImage(for: asset, targetSize: targetSize, contentMode: .aspectFit, options: options, resultHandler: { (image, info) in
if let image = image {
self.images.append(image)
self.assets.append(asset)
if self.selectedImage == nil {
self.selectedImage = image
}
}
DispatchQueue.main.async {
self.collectionView.reloadData()
self.hud.dismiss()
}
})
})
}
}
在 cellForItemAt 中,我尝试将索引加倍,以便加载下一个 10。我得到的结果是前 10 个帖子的无休止重复。 有人可以展示使用它的正确方法吗?
【问题讨论】:
标签: ios swift phasset photosframework