我正在尝试以下方法从本地标识符中获取资产并将其显示在集合视图中,但加载时滚动变得生涩。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "GridCell", for: indexPath) as! GridCell
cell.representedAssetIdentifier = "some uri"
let requestOptions = PHImageRequestOptions()
requestOptions.isSynchronous = false
let asset = PHAsset.fetchAssets(withLocalIdentifiers: ["some uri"!], options: .none).firstObject
imageManager.requestImage(for: asset!, targetSize: thumbnailSize, contentMode: .aspectFit, options: requestOptions, resultHandler: { result, info in
if cell.representedAssetIdentifier =="someuri" {
cell.imageview.image = result
}
})