【问题标题】:While using PHAssets getting this error: Creating an image format with an unknown type is an error使用 PHAssets 时出现此错误:Creating an image format with an unknown type is an error
【发布时间】:2017-04-06 04:49:50
【问题描述】:

为此,我创建了照片中所有缩略图图像的集合视图,我在下面编写了代码:

    var photoAssets: PHFetchResult<PHAsset> = PHFetchResult()

    let allPhotosOptions = PHFetchOptions()
    allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]

    let allPhotosResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: allPhotosOptions)

    photoAssets = allPhotosResult

现在我有 Array 的 PhotoAssets 用于为我编写的每个 PHAsset 获取缩略图:

    let manager = PHImageManager.default()
    let requestOptions = PHImageRequestOptions()
    public var thumbnailSize = CGSize(width: 100, height: 100)
    requestOptions.isSynchronous = true
    requestOptions.isNetworkAccessAllowed = true
    requestOptions.deliveryMode = .highQualityFormat
    requestOptions.resizeMode = .exact

    manager.requestImage(for: selectedAsset, targetSize: self.thumbnailSize, contentMode: PHImageContentMode.aspectFill, options: requestOptions) {
        image, info in
        // here I am getting the thumbnail image this code is running fine.
    }

当我从 UICollection 视图中选择任何缩略图图像时,我会获取索引并从 photoAssets 数组中获取 PHAsset。 现在为这个 PHAsset 创建完整尺寸的图像,我编写了代码:

    let manager = PHImageManager.default()
    let requestOptions = PHImageRequestOptions()
    public var thumbnailSize = CGSize(width: 100, height: 100)
    requestOptions.isSynchronous = true
    requestOptions.isNetworkAccessAllowed = true
    requestOptions.deliveryMode = .highQualityFormat
    requestOptions.resizeMode = .exact
    manager.requestImage(for: selectedAsset, targetSize: PHImageManagerMaximumSize, contentMode: PHImageContentMode.aspectFill, options: requestOptions) {
        image, info in
        //completion(image, info as AnyObject)
        //here i'll get the full size image for requested PHasset 
   }

我的问题是在为未启用 iCloud 的设备获取全尺寸图像时,我正在获取图像,但对于那些启用 iCould 的设备,我得到 image = nil创建未知类型的图像格式是错误的

【问题讨论】:

    标签: ios objective-c iphone image swift3


    【解决方案1】:

    创建未知类型的图像格式是错误的

    这是 xcode 中的一个错误,如果选择器可以正确选择并返回图像,则表示一切正常,请忽略它。

    【讨论】:

      猜你喜欢
      • 2022-12-27
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 2018-11-11
      • 1970-01-01
      • 2022-12-28
      相关资源
      最近更新 更多