简体   繁体   中英

While using PHAssets getting this error: Creating an image format with an unknown type is an error

I have created the Collection View of all Thumbnail image from Photos for doing this I have written code below:

    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

Now I have PhotoAssets of Array for fetching the thumbnail image for every single PHAsset I have written code :

    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.
    }

When I select any thumbnail image from the UICollection view I get the index and get the PHAsset from the photoAssets array. Now for creating the full size image for this PHAsset I written code :

    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 
   }

My problem is while getting the full size image for non iCloud enabled device the I am getting the image, but for those devices which is iCould enabled, i am getting image = nil and Creating an image format with an unknown type is an error

Creating an image format with an unknown type is an error

It's a bug in xcode , if picker could select and return images properly that means everything is okay , just ignore it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM