的項目所以我用下面的代碼來獲取所有從庫,做工精細的圖像:得到列表和全尺寸的圖像縮略圖時,點擊列表
func grabPhotos(){
let imgManager = PHImageManager.default()
let requestOptions = PHImageRequestOptions()
requestOptions.isSynchronous = true
requestOptions.deliveryMode = .highQualityFormat
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
if let fetchResults : PHFetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions){
if fetchResults.count>0{
for i in 0..<fetchResults.count{
imgManager.requestImage(for: fetchResults.object(at: i), targetSize: CGSize(width:100, height: 100), contentMode: .aspectFill, options: requestOptions, resultHandler: {
image, error in
self.Galleryimages.append(image!)
print("array count is ",self.Galleryimages.count)
self.photoCollectionview.reloadData()
})
}
}
}
}
我顯示所有圖片在我的UICollectionView,但我沒有找到任何方式獲得原始圖像,每當點擊任何縮略圖圖像。當用戶點擊UICollectionView中填充的任何縮略圖圖像時,我想獲取原始圖像(全尺寸圖像)。
謝謝。
意味着你想要做什麼? –
請看我編輯的問題,我實際上想要在用戶點擊任何縮略圖時獲取原始大小的圖像。 –
你不是在一個數組內存儲所有的圖像嗎?不能得到原始圖像是什麼意思? – KrishnaCA