相关疑难解决方法(0)

单击列表项时获取列表中的缩略图和全尺寸图像

所以我使用下面的代码从库中获取所有工作正常的图像:

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()
      })
      }

    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我在 UICollectionView 中显示所有图像,但我没有找到任何方法在单击任何缩略图时获取原始图像。当用户单击 UICollectionView 中填充的任何缩略图时,我想获取原始图像(全尺寸图像)。

谢谢。

iphone image-gallery ios phfetchoptions swift3

1
推荐指数
1
解决办法
3406
查看次数

标签 统计

image-gallery ×1

ios ×1

iphone ×1

phfetchoptions ×1

swift3 ×1